概述
展开全部
代码如下:public class Account {
private String accountNumber;
private String username;
private String identityCard;
private String level;
public static double accountBalance;
public String getAccountNumber() {
62616964757a686964616fe58685e5aeb931333363396334return accountNumber;
}
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getIdentityCard() {
return identityCard;
}
public void setIdentityCard(String identityCard) {
this.identityCard = identityCard;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public double getAccountBalance() {
return accountBalance;
}
public void setAccountBalance(double accountBalance) {
this.accountBalance = accountBalance;
}
// 存款
public void deposit(){ }
// 取款
public void withdrawal(){ }
// 统计
public void total(){
System.out.println(username + "的账户余额:" + accountBalance);
}
}public class Trans extends Account {
private String date;
private static char type;
private static double money;
public Trans(char type, double money){
this.type = type;
this.money = money;
}
@Override
public void deposit() {
Account.accountBalance = getAccountBalance() + money;
}
@Override
public void withdrawal() {
Account.accountBalance = getAccountBalance() - money;
}
}public class Test {
public static void main(String[] args) {
Account a = new Account();
a.setLevel("五星");
a.setUsername("张三");
a.setAccountBalance(55000);
Trans t1 = new Trans('C', 1000);
t1.deposit();
a.total();
Trans t2 = new Trans('Q', 6000);
t2.withdrawal();
a.total();
}
}
最后
以上就是彩色钥匙为你收集整理的java实验题_java实验题的全部内容,希望文章能够帮你解决java实验题_java实验题所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复