<java>我编的程序就是编译不过去 求解。。
关于方法重载的,包括用户名、口令等成员属性以及构造方法,获取和设置口令、显示和修改用户名的成员方法等
代码:
class Person
{
protected String name;
protected String password;
public void Person(String name,String password)
{
this.name=name;
this.password=password;
}
public void Person(String name)
{
this.name=name;
}
public String getname()
{
return name;
}
public String getpassword()
{
return password;
}
public void setname(String name1)
{
name=name1;
}
public void setpassword(String password1)
{
password=password1;
}
public void print(String name,String password)
{
System.out.println(name+password);
}
}
class Users extends Person
{
public Users(String name,String password)
{
super(name,password);
}
public void Student(Person n,String p)
{
super(n.getname(),p.getpassword());
}
}
public class UserText
{
public static void main(String args[])
{
Person p1=new Person(zhr,msy);
p1.print();
}
}
求解。。
Java 类
[解决办法]
public void Person(String name, String password) {
this.name = name;
this.password = password;
}
public void Person(String name) {
this.name = name;
}
public void Student(Person n, String p) {
super(n.getname(), n.getpassword());
}
public class UserText
{
public static void main(String args[])
{
Person p1=new Person(zhr,msy);
p1.print();
}
}
public class UserTest
{
public static void main(String args[])
{
Person p1=new Users("zhr","msy");
p1.print();
}
}