前面的东西学的还不是太扎实,东西确实多,时间感觉不够用,效率也比较低, 自己写过的代码都忘得差不多了,咋办啊!!
abstract class Teacher
{
private String name;
private int age;
public Teacher (){}
public void Teacher(String name,int age){
this.name=name;
this.age=age;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setAge(int age){
this.age=age;
}
public int getAge(){
return age;
}
public abstract void teach();
public void show(){
System.out.println(name+age);
}
}
class BaseTeacher extends Teacher
{
public BaseTeacher (){
System.out.println("基础班教师");
}
public void teach(){
System.out.println("基础班教Javase");
}
}
class WorkerTeacher extends Teacher
{
public WorkerTeacher (){
System.out.println("jiuye班教师");
}
public void teach(){
System.out.println("jiuye班教Javaee");
}
}
class Test4
{
public static void main(String[] args)
{
Teacher t=new BaseTeacher();
t.setName("夯哥");
t.setAge(20);
t.show();
t.teach();
t=new WorkerTeacher();
t.setName("dali");
t.setAge(19);
t.show();
t.teach();
} |
|