public interface Bank{
public void deposit(int money);
public void draw(int money);
}
public BankBook implements Bank{
public void deposit(int money){
deposits = deposits + money;
}
public void draw(int money){
if(money > deposits){
System.out.println("余额不足。");
}else{
deposits = deposits - money;
}
}
public String info(){
// 把所有属性拼成字符串。属性太多,省略.
String str = "姓名:" + name + " 账号:" + account + " 地址:" +......
System.out.println(str);
return str;
}
// 下面是属性定义,只示例其中2个,其它类似.
private String name;
private int deposits; // 存款额
.............
public String getName(){ return name; }
public void setName(String name){ this.name = name};
public int getDeposits(){ return deposits;}
public void setDeposits(int deposits){ this.deposits = deposits;}
}
写就see my name, find me