/**
*
*学生类
*/
public class Student {
// 学生的特征;在java中也称属性
String stuName;// 学生姓名
String stuGender;// 学生性别
int stuAge;// 学生年龄
String stuNo;// 学号
}
/**
* 老师类
*/
public class Teacher {
//老师的属性
String tName;
String tAge;
String tGender;
}
/**
*建筑物类
*
*/
public class Building{
//建筑的属性
String bTeachBuilding;
String bDormitory;
String bRestaurant;
//建筑的函数
public void classes(){
System.out.println( bTeachBuilding + "是上课的地方");
}
public void sleep(){
System.out.println(bDormitory +"是休息的地方");
}
public void eat(){
System.out.println(bRestaurant +"是吃饭的地方");
}
}
/**
*
*花园类
*/
public class Garden{
//花园的属性
String gScenery;
String gEntertainments;
public void nature() {
System.out.println(gScenery + "是花园的自然风景");
}
public void activity() {
System.out.println(gEntertainments + "是花园的运动建材");
}
}
/**
*
*操场类
*/
//操场的属性
public class PlayGround{
String pIndoorCourt;
String pOutdoorCourt;
//操场的函数
public void indoor() {
System.out.println(pIndoorCourt + "是室内运动的项目");
}
// 操场的方法
public void outdoor() {
System.out.println(pOutdoorCourt + "是室外运动的项目 " );
}
}
/**
*测试函数
*/
public class Text {
public static class School{
public String toString(){
return "this is School";
}
}
public static void main(String[] args){
// 创建一个学生对象
// 根据一个类创建一个对象的语法:类名称 变量名称(对象的引用) = new 类名称();
Student stu = new Student();
// 给这个对象的属性(特征)赋值
// 给对象的属性赋值:对象的引用.属性名称 = 值;
String [] stuName = new String[4];
stuName[0] = "阿梅";
stuName[1] = "阿红";
stuName[2] = "艳艳";
stuName[3] = "小悦";
int [] stuAge = new int[4];
stuAge[0] = 20;
stuAge[1] = 21;
stuAge[2] = 22;
stuAge[3] = 23;
String [] stuGender = new String[4];
stuGender[0] = "女";
stuGender[1] = "女";
stuGender[2] = "女";
stuGender[3] = "女";
String [] stuNo = new String[4];
stuNo[0] ="201207010103";
stuNo[1] ="201207010110";
stuNo[2] ="201207010112";
stuNo[3] = "20120701022";
System.out.println("学校的学生:" );
// 使用学生对象的属性
// 使用对象的属性:对象的引用.属性名称
for(int i = 0;i <=3;i ++){
System.out.println("学生的姓名:" + stuName[i]);
System.out.println("学生的年龄:" + stuAge[i]);
System.out.println("学生的性别:" + stuGender[i]);
System.out.println("学生的学号:" + stuNo[i]);
System.out.println("* * * * * * * * * * * * * * * * *:" );
}
//给老师对象的属性赋值
Teacher t = new Teacher();
String [] tName = new String[3];
tName[0] = "张三";
tName[1] = "李四";
tName[2] = "赵武";
String [] tGender = new String[3];
tGender[0] = "男";
tGender[1]= "男";
tGender[2] = "男";
int [] tAge = new int[3];
tAge[0] = 21;
tAge[1] = 26;
tAge[2] = 35;
System.out.println("学校的老师:");
//使用老师对象的属性
for(int j = 0;j <= 2; j ++){
System.out.println("老师的姓名:" + tName[j]);
System.out.println("老师的年龄:" + tAge[j]);
System.out.println("老师的性别:" + tGender[j]);
System.out.println("* * * * * * * * * * * * * * *" );
}
//给建筑物对象的属性赋值
Building b = new Building();
String [] bTeachBuilding = new String[3];
bTeachBuilding[0] = "信工楼";
bTeachBuilding[1] = "艺术";
bTeachBuilding[2] = "教学楼";
String [] bRestaurant = new String[3];
bRestaurant[0] = "一号餐厅";
bRestaurant[1] = "二号餐厅";
bRestaurant[2]= "清真餐厅";
String [] bDormitory = new String[3];
bDormitory[0] = "A栋";
bDormitory[1] = "B栋";
bDormitory[2] = "C栋";
System.out.println("学校的建筑物有:教学楼\t\t餐厅\t\t宿舍楼" );
//使用建筑物对象的属性
System.out.println("学校的教学楼有:" );
for(int j = 0;j < 3; j ++){
System.out.println("教学楼有:" + bTeachBuilding[j] );
b.classes();
}
System.out.println("* * * * * * * * * * * * * * *" );
System.out.println("学校的餐厅有:" );
for(int j = 0;j < 3; j ++){
System.out.println("餐厅有:" + bRestaurant[j]);
b.eat();
}
System.out.println("* * * * * * * * * * * * * * *" );
System.out.println("学校的宿舍楼有:" );
for(int j = 0;j < 3; j ++){
System.out.println("宿舍楼有:" + bDormitory[j] );
b.sleep();
}
System.out.println("* * * * * * * * * * * * * * * * * * *:" );
//给花园对象的赋值
Garden g = new Garden();
String [] gScenery = new String[3];
gScenery[0] = "花";
gScenery[1] = "树木";
gScenery[2] = "草坪";
String [] gEntertainments = new String[3];
gEntertainments[0] = "跑步机";
gEntertainments[1] = "跳跳板";
gEntertainments[2] = "秋千";
//使用花园对象的属性
System.out.println("花园的景色有:" );
for(int j = 0;j < 3; j ++){
System.out.println("景色:" + gScenery[j]);
g.nature();
}
System.out.println("* * * * * * * * * * * * * * *" );
System.out.println("花园的娱乐设施有:" );
for(int j = 0;j < 3; j ++){
System.out.println("娱乐设施:" + gEntertainments[j]);
g.activity();
}
System.out.println("* * * * * * * * * * * * * * * * * * *:" );
//给操场对象的赋值
PlayGround p = new PlayGround();
String [] pIndoorCourt = new String[3];
pIndoorCourt[0] = "乓乓球室";
pIndoorCourt[1] = "健美操馆";
pIndoorCourt[2] = "器材室";
String [] pOutdoorCourt = new String[3];
pOutdoorCourt[0] = "篮球场";
pOutdoorCourt[1] = "足球场";
pOutdoorCourt[2] = "排球场";
//使用操场对象的属性
System.out.println("室内的场地是:" );
for(int j = 0;j < 3; j ++){
System.out.println("室内设施:" + pIndoorCourt[j]);
p.indoor();
}
System.out.println("* * * * * * * * * * * * * * * * * * *:" );
System.out.println("室外的场地是:" );
for(int j = 0;j < 3; j ++){
System.out.println("室外设施:" + pOutdoorCourt[j]);
p.outdoor();
}
System.out.println("* * * * * * * * * * * * * * * * * * *:" );
Text school = new Text();
System.out.print(school);
}
}


