求助!!!对类进行增删改查,如何实现,并用单例模式。
1 类的继承
定义人员、学生、教师类(包含继承关系,学生和教师有自己特有的属性)
2 练习类的使用
定义学生管理、教师管理类(单例模式,四个功能(增删改查))
3 测试
定义测试类
分不多哦!
学生、教师类已有!
Student 类:
public Student(){
System.out.println("student无参");
}
public Student(String name,String sex,int age,String id,String hobby){
System.out.println("student有参");
}
double hight;
public double getHigth(){
return hight;
}
public void setHight(){
this.hight=hight;
}
public void study(){
System.out.println("我身高是"+hight);
}
public void show(){
StringBuffer sb=new StringBuffer();
sb.append("我的名字是:"+getName()+"我的年龄是:"+getAge()+"我的工号:"+getId()+"爱好是:"+getHobby());
System.out.print(sb.toString());
}
Teacher 类:
public class Teacher extends Person{
public Teacher(){
System.out.println("teacher无参构造");
}
public Teacher(String name,String sex,int age,String id,String hobby){
System.out.println("teacher有参构造");
}
private double higth;
public double getHigth(){
return higth;
}
private String place;
public String getPlace(){
return place;
}
public void setPlace(){
this.place=place;
}
public void teacher(){
System.out.println("我的年龄:"+getAge());
}
public void paly(){
System.out.println("我经常打在"+place);
}
public void H(){
System.out.println("我的身高是"+higth);
}