首页 > 其他 > 详细

小项目--bank2

时间:2016-03-31 20:27:57      阅读:336      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/alhh/p/5342540.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!