小项目--bank2
Posted ALHH
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小项目--bank2相关的知识,希望对你有一定的参考价值。
package banking2;
public class Customer {
private String firstName;
private String lastName;
private Account account;
public Customer(String f,String l){
firstName=f;
lastName=l;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public Account getAccount(){
return account;
}
public void setAccount(Account acct){
account = acct;
}
}
package testbanking1;
import banking2.*;
public class testbanking2 {
public static void main(String[] args){
Customer customer;
Account account;
account =new Account(500.00);
System.out.println("creating customer Jane Smith ");
customer =new Customer("Jane" ,"Smith");
customer.setAccount(account);//把account和customer联系起来
System.out.println("creating her account with 500.00 balance");
customer.getAccount().withdraw(150.00);
System.out.println("withdraw 150.00");
customer.getAccount().despoit(22.50);
System.out.println("despoit 22.50");
customer.getAccount().withdraw(47.62);
System.out.println("withdraw 47.62");
System.out.println("customer:"+customer.getFirstName()+customer.getLastName()+"account:"+account.getBalance());
}
}
以上是关于小项目--bank2的主要内容,如果未能解决你的问题,请参考以下文章