标签:
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());
	}
}
标签:
原文地址:http://www.cnblogs.com/alhh/p/5342540.html