추상 인터페이스 인 NamedAccount.java를 구현하는 BankAccount.java가 있는데, BankAccount.java가 추상화되지 않아 무시할 수 없다는 오류가 계속 발생합니다. 이 문제를 어떻게 수정합니까? 두 상황에서 @Override를 추가하려고 시도했지만 작동하지 않습니다!자바 오버라이드 추상 인터페이스 메서드
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);
}
하고이 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;
}
}
오류의 정확한 텍스트를 공유 할 수 있습니까? – Mureinik
인터페이스 구현은 인터페이스의 모든 메소드를 오버라이드/구현 (다른 단어, 동일한 것)해야 함을 의미합니다.'BankAccount' *는 이러한 메소드를 구현하지 않습니다. – immibis
"BankAccount.java가 추상이 아니기 때문에 재정의 할 수 없다는 오류가 계속 발생합니다." 아닙니다. * 실제 * 오류 메시지를 게시한다고 가정합니다. 그것의 일부 맹 글링 된 버전이 아닙니다. – EJP