public class LawClient extends Client
{
boolean defendant;
String caseTopic;
LawClient (String n, boolean d)
{
name = n;
defendant = d;
}
LawClient (String n, boolean d, String c, String e)
{
name = n;
defendant = d;
caseTopic = c;
email = e;
}
public String determineStatus()
{
if(caseTopic == null)
{
return "none";
}
else
{
String s = "";
s += "defendant: " + defendant +"\n" + "CaseTopic: " + caseTopic;
return s;
}
}
}
我得到2錯誤的法律客戶端構造函數沒有可變的構造函數,但不知道我做錯了什麼或如何解決它。抽象多態性和繼承的類賦值錯誤
這裏是超類,所以你可以運行它或看看它。
abstract class Client
{
protected String name;
protected double balance;
protected String email;
Client (String n)
{
name = n;
}
Client (String n, String e)
{
name = n;
email = e;
}
public String getName()
{
return name;
}
public double getBalance()
{
return balance;
}
public String getEmail()
{
return email;
}
public String setName(String a)
{
name = a;
return name;
}
public double adjustBalance(double b)
{
balance = b;
return balance;
}
public String setEmail(String e)
{
email = e;
return email;
}
public abstract String determineStatus();
public String toString()
{
String a = "";
a += "name: " +name + ("\n")+"Balance: " +balance + ("\n")+"Email: " +email + ("\n");
return a;
}
}
應該將構造函數公開嗎? – Taylor
是的,謝謝我錯過了,但它不能解決問題 – user2744515
顯示與錯誤pls的代碼。編輯:從頭開始。只要讀懂你的錯誤是在構造函數本身。構造函數應該在Client或Client中引用一個顯式的構造函數,但需要一個無參數構造函數。 – Taylor