我在使用此代码时遇到以下错误:
BankingServant is not abstract and does not override abstract method
CheckBalance(String) in BankingOperations public class BankingServant
extends _BankingImplBase
这是我的代码:
import BankingApp._BankingImplBase;
import BankingApp.*;
import java.util.ArrayList;
import java.util.Iterator;
public class BankingServant extends _BankingImplBase {
private int AccountName;
private int LodgementAmount ;
private int TransferAmount ;
private int WithdrawlAmount;
private int TransferAmount;
private int TransferAccWith;
private int TransferAccDep;
private int CheckBalance;
private class Account {
String accName;
}
private class Trans {
String accName;
double transferAmount;
double transferAccWith;
double transferAccDep;
double withAmount;
double lodgementAmount;
}
private class With {
String accName;
double withAmount;
}
public boolean Lodgement(String accName, double lodgementAmount) {
System.out.println("Enter Lodgement.");
Account acc = new Account();
acc.accName = accName;
acc.lodgementAmount = lodgementAmount;
acc.add(acc);
System.out.println("Money was lodged.");
}
public boolean Transfer(String accName, double transferAmount, double transferAccWith, double transferAccDep){
System.out.println("Transfer Amount: ");
Trans bankingTemp = new Trans();
bankingTemp.accName = accName;
bankingTemp.transferAmount = transferAmount;
bankingTemp.transferAccWith = transferAccWith;
bankingTemp.transferAccDep = transferAccDep;
bankingTemp.parts = this.parts;
bankingTemp.planeId = planeId;
banking.add(bankingTemp);
System.out.println("Transfered");
planeId++;
return true;
}
public void CheckBalance(String accName) {
System.out.println("Balance is: ");
Account accB = new Account();
accB.accName = accName;
accB.checkBalance = checkBalance;
accB.add(accB);
System.out.println("Balance is: ");
}
}
为什么我收到此错误?
答案 0 :(得分:1)
CheckBalance
和BankingServant
中的_BankingImplBase
方法可能有不同的签名。看起来它们具有相同的参数,因此它可能具有不同的返回类型。
答案 1 :(得分:1)
你有
private int CheckBalance;
和
public void CheckBalance(String accName) {
您可以遵循两种Java约定来阻止这样的事情:
您可以在此处找到有关命名约定的一些很好的参考资料: