求JAVA编成 急需!!!!!!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/14 14:22:56
1 有A B两个银行账户
2 向A账户存款5000元 进行余额确认
3 从B账户提取2000元 进行余额确认
把这3各条件 用JAVA 编成程序 谢谢大虾了!!!!!!!!!!!!!!

public class Account {
private String accountId;
private double money;
public Account(String accountId) {
this.accountId = accountId;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public double getMoney() {
return money;
}
public void setMoney(double money) {
this.money = money;
}
public void addMoney(double money) {
this.money = this.money + money;
System.out.println("帐户" + this.accountId + "余额为:" + this.money);
}
public void subMoney(double money) {
this.money = this.money - money;
System.out.println("帐户" + this.accountId + "余额为:" + this.money);
}
public static void main(String[] args) {
Account A = new Account("A");
Account B = new Account("B");
A.addMoney(5000.00);
B.subMoney(2000.00);
}