您的当前位置:首页正文

Account (Java)

2020-07-14 来源:爱go旅游网


package xu;

public abstract class Account {

private int id;

protected String Name;

private double qian;

public static int CurrentID = 100;

//开户时调用的构造方法

public Account(String Name, double balance) {

this.Name = Name;

this.qian = balance;

id = CurrentID++;

}

//读取文件加载数据时用的构造方法

public Account(int id, String Name, double qian) {

this.id = id;

this.Name = Name;

this.qian = qian;

}

public static int getCurrentID() {

return CurrentID;

}

public static void setCurrentID(int currentID) {

CurrentID += currentID;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return Name;

}

public void setName(String name) {

this.Name = name;

}

public double getQian() {

return qian;

}

public void setQian(double qian) {

this.qian = qian;

}

// 存款

public void deposit(double money) {

qian += money;

}

// 取款

public void withdraw(double money) throws BalanceNotEnoughException {

if (qian < money) {

throw new BalanceNotEnoughException(\"余额不足!\");

} else {

qian -= money;

}

}

//查询

@Override

public String toString() {

// TODO Auto-generated method stub

return id + \"\\" + Name + \"\\" + qian;

}

public abstract double interest();

}

因篇幅问题不能全部显示,请点此查看更多更全内容