package com.g.x.fengzhuang;
public class CustomTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Customer cust = new Customer("hh", "lll");
Account acc = new Account(1001, 2000, 0.0136);
cust.setAccount(acc);
cust.getAccount().deposit(33);
cust.getAccount().getId();
System.out.println(cust.getAccount().getId());
}
}
****************************************************
package com.g.x.fengzhuang;
public class Account {
private int id;//账号
private double balance;//余额
private double annualInterestRate;//年利率
public Account() {
super();
}
public Account(int id, double balance, double annualInterestRate) {
super();
this.id = id;
this.balance = balance;
this.annualInterestRate = annualInterestRate;
}
public void withdraw(double amount) { //取钱
if (amount > balance) {
System.out.println("no money");
}
balance -= amount;
System.out.println("out success:"+amount);
}
public void deposit(double amount) { //存钱
if (amount > 0) {
balance += amount;
System.out.println("input success :"+amount);
}
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getAnnualInterestRate() {
return annualInterestRate;
}
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}
}
***********************************************************
package com.g.x.fengzhuang;
public class Customer {
private String firstname;
private String lasename;
private Account account;
public Customer() {
super();
}
public Customer(String firstname, String lasename, Account account) {
super();
this.firstname = firstname;
this.lasename = lasename;
this.account = account;
}
public Customer(String f,String l) {
this.firstname = f;
this.lasename = l;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLasename() {
return lasename;
}
public void setLasename(String lasename) {
this.lasename = lasename;
}
public Account getAccount() {
return account;
}
public void setAccount(Account account) {
this.account = account;
}
}