package com.demo;
public class Teacher {
private static double xishu=1.2;//课时数量,定义成static类型保证有教师的课时系数都相同
private double classNo=0.0;//课时数量
public Teacher(){
}
public Teacher(double classNo){//构造函数
this.classNo=classNo;
}
public double courseCompute( ){
return xishu*classNo;
}
public static void main(String[] string){
Teacher teacherOne=new Teacher(4);//申明一个四节课时的教师
Teacher teacherTwo=new Teacher(5);//申明一个四节课时的教师
System.out.println(teacherOne.courseCompute());//输出结果
System.out.println(teacherTwo.courseCompute());
teacherOne.xishu=1;//修改系数
System.out.println(teacherOne.courseCompute());//重新输出结果
System.out.println(teacherTwo.courseCompute());
}
}
运行结果: