码迷,mamicode.com
首页 > 其他好文 > 详细

小项目--bank2

时间:2016-03-31 20:29:26      阅读:158      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!