📄 moni.java
字号:
/*
* 写一个程序,实现对学校集体的一个模拟,初步设计为:父类是学生(student),接下来是宿舍(room),接下来是
* 班级(class),再接下来是院(college),再下来就是学校,进行少许的初始化,实现?
* */
class student{
protected
String stuName;
int stuId;
String sex;
int age;
student(){
System.out.println("The ifo of the student is:");
System.out.println("stuId stuName sex age");
}
}
class room extends student{
protected
int roomId;
int roomManNum;
room(){
System.out.println("The room is"+this.roomId+":");
System.out.println("the number of the room is:"+this.roomManNum);
}
}
class Class extends room{
protected
int ClassId;
int ClassNum;
Class(){
System.out.println("The class ID is:"+this.ClassId);
System.out.println("The number of the student of the class is:"+this.ClassNum);
}
}
class college extends Class{
protected
String collegeName;
int collegeNum;
college(){
System.out.println("The name of the college is;"+this.collegeName);
System.out.println("The number of the class of the college is:"+this.collegeNum);
}
}
public class MoNi{
public static void main(String[] s){
student stu =new student();
stu.stuId=13051067;
stu.stuName = "yangyelong";
stu.sex="male";
stu.age=23;
System.out.println(stu.stuId+"-"+stu.stuName+"-"+stu.sex+"-"+stu.age);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -