「南通青鸟 IT 教育 103 班同学在 3 教室上崔老师的 Java 课」

 
 
package dodoke;

public class student{  
    // 成员变量  
	String name;    //学生姓名 
	int age;        //学生年龄
    String clazz;   //班级  
    String room;    //教室  
    String group;   //小组   
    String address; //学生住址  
    String teacher; //教学老师  
    String course;  //课程  
    // 类变量  
    static String school = "渡课IT(原名青鸟IT)";  
    static String schooladdress = "南通市崇川区跃龙南路182号数字大厦二楼";  
    static String schoolhistory = "12年";  
      
    // 方法  
    void Classing() {  
        System.out.println(this.teacher + "正在" + this.room + "给" + this.clazz + "上" + this.course);  
    }  
      
    String  CourseTeacher() {  
        return this.course + "由" + this.teacher + "负责";  
    }   
      
    static String SchoolInfor() {  
        return school + "位于" + schooladdress + "已经有" + schoolhistory + "的历史了";  
    }  
      
    //创建自定义类型返回值为TeacherInformation的对象  
    TeacherInformation techer (String gender,int teacherage, String teacheradrress) {  
        return new TeacherInformation (gender, teacherage, teacheradrress);  
    }  
      
    //默认构造器  
    public student() {  
    }  
    //构造器重载  
    public student(String clazz, String room, String name, int age,String teacher,String course) {  
        this.clazz = clazz;  
        this.room = room;  
        this.name = name;  
        this.age = age;  
        this.teacher = teacher;  
        this.course = course;  
    }  
  
}
package dodoke;  
  
public class TeacherInformation {  
    //成员变量  
    String gender;  
    int teacherage;  
    String teacheradrress;  
      
    //方法  
    void information() {  
        System.out.println(this.teacherage + "岁以上的" + this.gender + "老师住在" + this.teacheradrress);  
    }  
      
    //创建自定义数据类型为TeacherInfor的方法  
    String information1(TeacherInformation TeacherInformation1) {  
        return TeacherInformation1.teacherage + "岁以上的" + TeacherInformation1.gender + "老师住在" + TeacherInformation1.teacheradrress;  
    }  
  
    //构造器  
    public TeacherInformation(String gender, int teacherage, String teacheradrress) {  
        this.gender = gender;  
        this.teacherage = teacherage;  
        this.teacheradrress = teacheradrress;  
    }  
}

package dodoke;

public class client {
	  public static void main(String[] args) {  
	        /*********创建学生对象*******/  
	        student stu = new student("java103", "三教室", "tom", 25, "崔老师", "java基础");  
	          
	        /********对象调用方法********/  
	        stu.Classing();//崔老师正在三教室给java103上java基础  
	          
	        System.out.println(stu.CourseTeacher());//java基础由崔老师负责  
	          
	        /*********类对象调用********/  
	        //渡课IT位于南通市崇川区跃龙南路182号数字大厦二楼已经有12年的历史了  
	        System.out.println(student.SchoolInfor());  
	          
	          
	        /********创建教师信息对象(方法一 )直接new创建*********/  
	        TeacherInformation tcInfor  = new TeacherInformation("男", 20, "崇川区");  
	          
	        //20岁以上的男老师住在崇川区  
	        tcInfor.information();   
	          
	        /********创建教师信息对象(方法二)通过方法返回一个对象********/  
	        TeacherInformation teacherInfor1 = stu.techer("女", 20, "开发区");  
	          
	        //20岁以上的女老师住在开发区  
	        System.out.println(teacherInfor1.information1(teacherInfor1));  
}
}



猜你喜欢

转载自blog.csdn.net/readygoing/article/details/80215328