我在实现我的子类客户时遇到问题我得到了预期的错误58:“number =”“;”我试图让客户类继承我的Person类中的方法。
到目前为止我的计划:
import java.util.Scanner;
public class Person
{
private String name;
private String address;
private String number;
public Person() //No Argument constructor//
{
name= "";
address= "";
number= "" ;
}
public Person(String num, String nam, String add) //Explicit value constructor//
{
number= num;
name= nam;
address= add;
}
public String getName() //Accessor method//
{
return name;
}
public void setName(String name )//Mutator method//
{
this.name= name;
}
public String getAddress()
{
return address;
}
public void setAddress(String address)
{
this.address= address;
}
public String getTelephoneNumber()
{
return number;
}
public void setNumber(String number)
{
this.number= number;
}
public String toString ()
{
return name + "\n" + address + "\n" + number;
}}
public class Customer extends Person
{
number="";
public Customer(String num, String nam, String add)
{
super (number);
}
public void addChoice(String number, boolean correct)
{
choice.add(choice);
if (correct)
{
setAnswer(choiceString);
}
}
public void display()
{
super.display();
}
}
答案 0 :(得分:2)
它是什么非常简单。在声明}
之后,您不小心放了一个右括号{
而不是左括号getName
。真的很容易修复。