程序有误,关于父类子类的问题
class Person{
String name,sex;
int age;
void set(String n,String s,int a)
{
name=n;
sex=s;
age=a;
}
void show()
{
System.out.println("父类的姓名属性的值为:"+name);
System.out.println("父类的性别属性的值为:"+sex);
System.out.println("父类的年龄属性的值为:"+age);
}
}
class Student extends Person
{
String major,cla;
int num;
void sets(String m,String c,int n)
{
major=m;
cla=c;
num=n;
}
void shows()
{
System.out.println("子类的专业属性的值为:"+major);
System.out.println("子类的班级属性的值为:"+cla);
System.out.println("子类的学号属性的值为:"+num);
}
}
public class shiyan2 {
public static void main(String args[])
{
Student me=new Student();
me.sets("通信","通信0904",2009010472);
me.set("刘晓凯", "女", 21);
me.show();
me.shows();
}
}
老师说用 set 不能用sets 我也不明白什么意思。。。寻求帮助!!