package Home_work;
class Pople{
String name;
String sex;
Pople(){}
Pople(String name ,String sex){
this.name=name;
this.sex=sex;
};
public void setName(String name){
this.name=name;
}
public void setSex(String sex){
this.sex=sex;
}
public String getName(){
return this.name;
}
public String getSex(){
return this.sex;
}
}
class Student extends Pople{
int id;
int age;
Student(){};
Student(int id,int age){
this.id=id;
this.age=age;
};
public void setId(int id){
this.id=id;
}
public void setAge(int age){
this.age=age;
}
public int getId(){
return this.id;
}
public int getAge(){
return this.age;
}
public String toString(){
System.out.println("姓名:"+name+" 年龄:"+age+" 学号:"+id+" 性别:"+sex);
return name;
}
}
public class SDome {
public static void main(String[] args) {
Student zs = new Student();
zs.name = "张三";
zs.sex="男";
zs.id=20201222;
zs.age = 18;
zs.toString();
Student ls = new Student();
ls.name = "李四";
ls.sex="男";
ls.id=12345678;
ls.age = 22;
ls.toString();
}
}
```python
在这里插入代码片