i need to print customer[1] is abcd,cbnb using array

i need to print customer[1] is abcd,cbnb using array

print("code sample");

package bankprj3;

class Account { private double Balance;

public Account(double initBalance){ Balance=initBalance; } public double getBalance(){ return Balance; } public boolean deposit(double amt){ Balance=Balance+amt; return true; } public boolean withdraw(double amt){ if(Balance>=amt){ Balance=Balance-amt; return true; } else return false; } }

class Customer { public String firstname; public String lastname; private Account account; Customer(String f,String l){ firstname=f; lastname=l; } String getfirstname(){ return firstname;

 }
 String getlastname(){
     return lastname;

 }
 Account getAccount(){
     return account;

 }
 void setAccount(Account acct){
     account=acct;
 }

} class Bank { public Customer customers[]; private int noofcustomers; Bank() {

      customers=new Customer[10];
       noofcustomers=0;

 }
 public void addCustomer(String f,String l) {
      int i=noofcustomers++;
     customers[i]=new Customer(f,l);


 }
 public int getnoofcustomers(){
     return noofcustomers;
 }
 public Customer getcustomer(int customer_index) {
     return customers[customer_index];
 }

} public class Main {

public static void main(String[] args) {
    Bank b=new Bank();

   b.addCustomer("simms","jane");
   System.out.println( b.getnoofcustomers());
   b.addCustomer("abcd","cdnb");
   b.addCustomer("mnkn","ncdj");
   System.out.println( b.getnoofcustomers());
  for(int i=0;i<5;i++)
  {
 System.out.println(b.getcustomer(i));
    }


}

}

View Answers









Related Tutorials/Questions & Answers:

Ads