class Day_XueSheng {
public static void main(String[] args) {
BassXueSheng bs = new BassXueSheng("小魏子",18);
bs.Study();
OverXueSheng os = new OverXueSheng("大魏子",19,"女");
os.Study();
}
}
abstract class XueSheng {
private String name;
private int age;
public XueSheng(){}
public XueSheng(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 BassXueSheng extends XueSheng{
public BassXueSheng(){}
public BassXueSheng(String name,int age){
super (name,age);
}
public void Study (){
System.out.println("我的名字是" + getName() + ",年龄是" + getAge() + ",我的学习任务是Java基础");
}
}
class OverXueSheng extends XueSheng{
private String xingbie ;
public OverXueSheng(){}
public OverXueSheng(String name,int age,String xingbie){
super (name,age);
this.xingbie = xingbie;
}
public void Study (){
System.out.println("我的名字是" + getName() + ",年龄是" + getAge() + ",我的性别是" + xingbie + ",我的学习任务是Android");
}
}
|
|