第四次实训作业
写“电费管理类”及其测试类。
•第一步 编写“电费管理”类
•私有属性:上月电表读数、本月电表读数
•构造方法:无参、2个参数
•成员方法:getXXX()方法、setXXX()方法
•成员方法:显示上月、本月电表读数
public class electric {
private int next,the;
double x=1.2,y;
public electric(){
}
public electric(int next,int the){
this.next=next;
this.the=the;
}
public void setNext(int next){
this.next=next;
}
public void setThe(int the){
this.the=the;
}
public void printE(){
System.out.println("上个月电表数:"+next+"这个月电表数:"+the);
}
public int printF(){
y=(the-next)*x;
System.out.println("电费数:"+y);
return 0;
}
}
浙公网安备 33010602011771号