我有一个抽象类,有4种记入,借记,存款和取款的方法。我不知道如何设置贷记和借记账户的方法,因为我认为这与存款和取款相同,但我不相信。她已经提供了一个测试工具,所以我只需要设置课程。这是抽象类
abstract public class Account implements PostInterest
{
private String fName;
private String lName;
private String nbrSSN;
private char acctStatus = 'A';
private double balance = 0.0;
//five-argument constructor
public Account(String first, String last, String ssn, char status, double begBalance)
{
setName(first);
setLast(last);
setSSN(ssn);
setStatus(status);
setBalance(begBalance);
}
public Account(String first, String last, String ssn)
{
setName(first);
setLast(last);
setSSN(ssn);
}
public void setName(String first)
{
fName = first;
}
public String getName()
{
return fName;
}
public void setLast(String last)
{
lName = last;
}
public String getLast()
{
return lName;
}
public void setSSN(String ssn)
{
nbrSSN = ssn;
}
public String getSSN()
{
return nbrSSN;
}
public void setStatus(char status)
{
acctStatus = status;
}
public char getStatus()
{
return acctStatus;
}
public void setBalance(double begBalance)
{
balance = begBalance;
}
public double getBalance()
{
return balance;
}
public abstract void debitAccount(double amount);
public abstract void creditAccount(double amount);
public abstract void deposit(double amount);
public abstract void withdraw(double amount);
}
这是我节省的课程之一。我还需要其他一些课程,但如果有意义的话,我会在设置信用卡和借记卡时与存款和取款相比存在差异。
public class Savings extends Account
{
private double intRate;
public Savings(String first, String last, String ssn, double begBalance, double rate)
{
super(first, last, ssn, begBalance);
setRate(rate);
}
Public Savings(String first, String last, String ssn, double rate)
{
super(first, last, ssn);
setRate(rate);
}
public void setRate(double rate)
{
intRate = rate;
}
public double getRate()
{
return intRate;
}
@Override
public void debitAccount(double amount)
{
}
@Override
public void creditAccount(double amount)
{
}
@Override
public void deposit(double amount)
{
balance += amount;
}
@Override
public void withdraw(double amount)
{
if(amount > balance)
{
balance = -1;
}
else
{
balance -= amount;
}
}
@Override
public void postMonthly()
{
((intRate/12)* balance);
}
}
我还没有设置postMonthly方法,但她希望我们根据当前余额和intRate计算月份的利息,并调用creditAcct(),传递利息计算结果,这让我有点困惑。任何帮助将不胜感激!