I have a BankAccount.java that implements NamedAccount.java which is an abstract interface, but it keeps giving me an error that since BankAccount.java is not abstract it can't override it. How do I fix this problem? I tried adding @Override in both situations but it does not work!
BankAccount.java:
public class BankAccount implements NamedAccount {
private String myCustomer;
private double myBalance;
private double myInterest;
protected int myMonthlyWithdrawCount;
protected double myMonthlyServiceCharges;
public BankAccount(final String theNameOfOwner,
final double theInterestRate) {
myCustomer = theNameOfOwner;
myInterest = theInterestRate;
myBalance = 0.0;
myMonthlyWithdrawCount = 0;
myMonthlyServiceCharges = 0;
}
public double getBalance() {
return myBalance;
}
public boolean processDeposit(final double theAmount) {
boolean trueDeposit = false;
if (theAmount > 0) {
myBalance += theAmount;
trueDeposit = true;
}
return trueDeposit;
}
public boolean processWithdrawal(final double theAmount) {
boolean trueWithdrawal = false;
if (theAmount > 0 && theAmount > myBalance) {
myBalance -= theAmount;
trueWithdrawal = true;
}
return trueWithdrawal;
}
public double calculateInterest() {
return myBalance * (myInterest / 12.0);
}
public void performMonthlyProcess() {
myBalance -= myMonthlyServiceCharges;
myBalance += calculateInterest();
myMonthlyWithdrawCount = 0;
myMonthlyServiceCharges = 0.0;
if (myBalance < 0.0) {
myBalance = 0.0;
}
}
}
NamedAccount.java:
public interface NamedAccount {
String getAccountHolderName();
void setAccountHolderName(final String theNewName);
}
and to make it run you'll need this SafeDepositBoxAccount.java:
public class SafeDepositBoxAccount implements NamedAccount {
private String mySafeName;
public SafeDepositBoxAccount(final String theNameOfHolder) {
mySafeName = theNameOfHolder;
}
public String getAccountHolderName() {
return mySafeName;
}
public void setAccountHolderName(final String theNewName) {
mySafeName = theNewName;
}
}
BankAccountdoesn't implement those methods.