按要求编写Java应用程序。 (1)定义Teacher类,具有属性:教师的姓名、年龄、教授的课程以及是否担任班主任,方法printInfo输出教师的姓名、年龄和所教授的课程,构造方法为成员变量
public class Teacher { String name; int age; String course; boolean tutor; public Teacher(String name, int age, String course, boolean tutor) { super(); this.name = name; this.age = age; this.course = course; this.tutor = tutor; } void printInfo(){ System.out.println("姓名"+name); System.out.println("年龄"+age); System.out.println("授课名称"+course); } } public class Team { String className; Teacher tutor; public Team(String className, Teacher tutor) { super(); this.className = className; this.tutor = tutor; } void show(){ System.out.println("班级:"+className); } } public class Test9 { public static void main(String[] args) { Teacher MyTeacher=new Teacher("文文",35,"韩语",true); Team MyTeam=new Team("10班", MyTeacher); MyTeam.show(); MyTeam.tutor.printInfo(); } }