我有2個子類和一個超類。我嘗試運行測試文件但不工作。任何建議?測試文件錯誤
錯誤:https://i.imgur.com/ciG9EPF.png
第一個文件,超類(單人牀=人)
package proj;
public class persoana {
private String name, address, phone, email;
public persoana(){
}
public persoana(String name, String address, String phone, String email) {
this.name = name;
this.address = address;
this.phone = phone;
this.email = email;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getAddress(){
return address;
}
public void setAddress(String address){
this.address = address;
}
public String getPhone(){
return phone;
}
public void setPhone(String phone){
this.phone = phone;
}
public String getEmail(){
return phone;
}
public void setEmail(String email){
this.email = email;
}
}
文件2是僱員,對於單人牀亞類:
package proj;
public class employee extends persoana{
private String office, salary;
public employee(){
}
public employee(String office, String salary){
this.office = office;
this.salary = salary;
}
public String office(){
return office;
}
public void setOffice(String office){
this.office = office;
}
public String getSalary(){
return salary;
}
public void setSalary(String salary){
this.salary = salary;
}
}
文件3,類的子類persoana:
package proj;
public class student extends persoana{
private String bac, adm;
public student(){
}
public student(String bac, String adm){
this.bac = bac;
this.adm = adm;
}
public String bac(){
return bac;
}
public void setBac(String bac){
this.bac = bac;
}
public String getAdm(){
return adm;
}
public void setAdm(String adm){
this.adm = adm;
}
}
在哪裏出現在6號線2級的錯誤和7
package proj;
public class test {
public static void main(String[] args) {
persoana persoana= new persoana ("John", "Somewhere", "415",
"[email protected]");
persoana student= new student("Jane", "School Street", "650", "[email protected]");
persoana employee= new employee ("Tom ", "Street", "408", "asd");
System.out.println(persoana.toString() + "\n");
System.out.println(student.toString() + "\n");
System.out.println(employee.toString() + "\n");
}
}
歡迎來到Stack Overflow!請編輯您的問題以包含一個最小可重現的示例:https://stackoverflow.com/help/mcve。這將幫助我們專注於實際問題而不解析所有代碼:) – FunkySayu