Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Java Objects (http://www.go4expert.com/forums/java-objects-t13925/)

cyrow 16Sep2008 04:36

Java Objects

public class Account{
        //class Variables
        private static int NumAccounts = 0;
        private static final double Interest = 0.05;
        //Instant Variables
        private long accNum;
        private double balance;
        public Account(long accN, double bal){
                accNum  = accN;
                balance = bal;
        public int GetNumAccounts(){
                return NumAccounts;
        public double getBalance(){
                return balance;
        public long getAccountNum(){
                return accNum;
        public void debit(double amount){
                if(amount > balance){
                        System.out.println("Insufficient Funds in your Account");
                        balance = balance - amount;
        public void credit(double amount){
                balance += amount;
        public String toString(){
                String Str;
                Str ="Account Number  :" + accNum + "\n"+
                        "Account Balance  :" + balance + "\n";
                return Str;
}//End of class Account

public class TestAccount{
static Account[]accList= new Account[100];


public static void insertIntoArray(Account p){//Insert Objects into account
                int u  = 1;               
                accList[u++] = p;

public void  print(){ // Print objects
                System.out.println("Account Number :" + accNum);
                System.out.println("Balance        :" + balance);

        public static void main(String[] args){
          // Account []accList = new Account[1000];
        Account        a = new Account(123456,5255.17);
        Account        b = new Account(188468,19218.20);
        Account        c = new Account(217794,1002.62);
        Account        d = new Account(998283,20203.75);

        for(int i = 1; i <= 4; i++){// print array elements

        }//end main
}//end class TestAccount

Issues with the TestAccount class
I am to assume an array, accList, to hold Accounts objects. TestAccount has a method insertIntoArray(Account). Next, I am to create four account objects, insert them into the array and then print them. When I try to print I am getting the following errors:
Cannot find symbol variable accNum;
Cannot find symbol variable balance;
Cannot find symbol method print();

All times are GMT +5.5. The time now is 17:09.