面向对象的几个问题
·(1)编写老师类,要求有属性:姓名name,年龄age,职称post,基本工资salary·(2)编写业务方法:introduce(),实现输出一个教师的信息
·(3)编写教师类的三个子类:教授类(Professo)、副教授类、讲师类,工资级别分为:教授1.3、副教授1.2、讲师类1.1。再三个子类重写父类的introduce()方法
·(4)定义并初始化一个老师对象,调用业务方法,实现对象基本信息的后台打印。 来了啊,你这个没讲清楚,能说的清楚一点吗?
public class Teacher {
public static void main(String[] args) {
Introduce introduce = new Introduce();
Teacher teacher = new Teacher();
String name = "王芳芳";
int age = 18;
String post = "讲师";
double salary = 0;
if (post == "教授"){
salary = introduce. professo();
}else if (post == "副教授"){
salary = introduce.assprofessor();
}else if (post == "讲师"){
salary = introduce.teacher();
}
teacher.Teacher(name,age,post,salary);
}
void Teacher(String name,int age,String post,double salary){
System.out.println("名字是"+name);
System.out.println("年龄是"+age);
System.out.println("职业是"+post);
System.out.println("工资有"+salary);
}
}
class Introduce {
double professo(){
return 1.3;
}
double assprofessor(){
return 1.2;
}
double teacher() {
return 1.1;
}
}
亲,这是不是你想要的呢?如果是请设置最佳答案啊!谢谢啦。
页:
[1]