Account类://balance(余额)withdraw(取出)deposit(存入)
class Account{
public boolean ture;
protected double balance;
public Account(){
balance = 0;
}
public Account(double init_balance){
balance=init_balance;
}
public double getBalance(){
return balance;
}
public boolean deposit(double amt){
if(amt>0){
balance = balance + amt;
return ture;
}
else {
return false;
}
}
public boolean withdraw(double amt) {
if((balance-amt)>0){
balance = balance - amt;
return ture;
}
else return false;
}
}
要求编写一个CheckingAccount子类
-overdraftprotection :double+CheckingAccount(balance:double)
+CheckingAccount(balance:double,protect:double)
+withdraw(amt:double):boolean
该怎么写啊 刚开始写程序 老师就布置这样的题 做不出来 郁闷中 各位大大帮帮忙啊!!!
class Account{
public boolean ture;
protected double balance;
public Account(){
balance = 0;
}
public Account(double init_balance){
balance=init_balance;
}
public double getBalance(){
return balance;
}
public boolean deposit(double amt){
if(amt>0){
balance = balance + amt;
return ture;
}
else {
return false;
}
}
public boolean withdraw(double amt) {
if((balance-amt)>0){
balance = balance - amt;
return ture;
}
else return false;
}
}
要求编写一个CheckingAccount子类
-overdraftprotection :double+CheckingAccount(balance:double)
+CheckingAccount(balance:double,protect:double)
+withdraw(amt:double):boolean
该怎么写啊 刚开始写程序 老师就布置这样的题 做不出来 郁闷中 各位大大帮帮忙啊!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货