具体事物:基础班学生,就业班学生
共性:姓名,年龄,学习
特性:
基础班学生学JavaSE
就业班学生学Android
class Text_Student {
public static void main(String[] args) {
BaseStudent bt = new BaseStudent("张三",28);
System.out.println(bt.getName()+" "+bt.getAge());
bt.study();
JiuStudent jt = new JiuStudent("李四",29);
System.out.println(jt.getName()+" "+jt.getAge());
jt.study();
}
}
abstract class Student {
private String name;
private int age;
public Student (){}
public Student (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 study();
}
class BaseStudent extends Student{
public BaseStudent(){}
public BaseStudent(String name,int age){
super(name,age);
}
public void study(){
System.out.println("基础班学生学JavaSE");
}
}
class JiuStudent extends Student{
public JiuStudent(){}
public JiuStudent(String name,int age){
super(name,age);
}
public void study(){
System.out.println("就业班学生学Andriod");
}
}
class Text_Student {
public static void main(String[] args) {
BaseStudent bt = new BaseStudent("张三",28);
System.out.println(bt.getName()+" "+bt.getAge());
bt.study();
JiuStudent jt = new JiuStudent("李四",29);
System.out.println(jt.getName()+" "+jt.getAge());
jt.study();
}
}
abstract class Student {
private String name;
private int age;
public Student (){}
public Student (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 study();
}
class BaseStudent extends Student{
public BaseStudent(){}
public BaseStudent(String name,int age){
super(name,age);
}
public void study(){
System.out.println("基础班学生学JavaSE");
}
}
class JiuStudent extends Student{
public JiuStudent(){}
public JiuStudent(String name,int age){
super(name,age);
}
public void study(){
System.out.println("就业班学生学Andriod");
}
} |
|