class Untitled {
public static void main(String[] args) {
Customer tom=new Customer("tom","1000",2000,0.05);
tom.Ac.deposit(2000);
}
}
class Customer{
private String name;
Account Ac;
public Customer(){}
public Customer(String name,String iD,double balance,double annualInterestRate){
this.name = name;
this.Ac = new Account(iD,balance,annualInterestRate);
}
}
class Account{
private String iD;
private double balance;
private double annualInterestRate;
public Account(){}
public Account(String iD,double balance,double annualInterestRate){
this.iD = iD;
this.balance = balance;
this.annualInterestRate = annualInterestRate;
}
public void setiD(String iD){
this.iD=iD;
}
public void getiD(){
System.out.println("iD:"+this.iD);
}
public void setbalance(double balance){
this.balance=balance;
}
public void getbalance(){
System.out.println("balance:"+this.balance);
}
public void setannualInterestRate(double annualInterestRate){
this.annualInterestRate = annualInterestRate;
}
public void getannualInterestRate(){
System.out.println("annualInterestRate:"+this.annualInterestRate);
}
public void deposit(double demoney){
this.balance += demoney;
System.out.println("存款成功,当前余额为:"+this.balance);
}
public void withdraw(double wdmoney){
if(this.balance >= wdmoney){
this.balance -= wdmoney;
System.out.println("取款成功,当前余额为:"+this.balance);
}
else{
System.out.println("余额不足,取款失败");
}
}
}