public class Teacher {
String name;
String sex;
int age;
String course;
String result;
public Teacher(String name,String sex,int age,String course){
this.name=name;
this.sex=sex;
this.age=age;
this.course=course;
setResult(1);
System.out.print(getDetails());
}
public boolean setCourse(String course){
String old=this.course;
this.course=course;
if (old==this.course) return true;
else return false;
}
public String getCourse(){
return this.course;
}
public boolean setResult(int re){
if (re==1) {
this.result="优秀";
return true;
}
else if(re==2) {
this.result="良好";
return true;
}
else if(re==3) {
this.result="一般";
return true;
}
else if(re==3){
this.result="差";
return true;
}
else return false;
}
public String getDetails(){
String info="姓名:"+name+" 性别:"+sex+" 年龄:"+age+" 课程:"
+course+" 效果:"+result;
return info;
}
public static void main(String[] args) {
new Teacher("刘某","男",30,"java"); }}