✔ 最佳答案
import javax.swing.*;
class Workman{
private int idNum;
private int hours=8;
private boolean special=false;
private static int count=0;
private static final double RATE1=8.6;
private static final double RATE2=7.3;
public Workman(int num) {
idNum=num;
count++;
}
public Workman(int n1, int n2) {
idNum=n1;
hours=n2;
count++;
}
public Workman(int n1, int n2, boolean special) {
idNum=n1;
hours=n2;
this.special=special;
count++;
}
public static int getCount() {
return count;
}
/*
public void setSpecial(boolean special){
boolean x;
special=x;
}
public int getNum() {
return idNum;
}
*/
public double getPay() {
double pay;
if (special==true)
pay=hours*RATE1;
else
pay=hours*RATE2;
return pay;
}
}//end of classWorkman
public class TestWorkman {
public static void main (String[] arg) {
Workman id801 = new Workman(801);
System.out.println("The pay of idNum: 801 is " + id801.getPay() );
Workman id802 = new Workman(802, 10);
System.out.println("The pay of idNum: 802 is " + id802.getPay() );
Workman id803 = new Workman(803, 12, true);
System.out.println("The pay of idNum: 803 is " + id803.getPay() );
}//end of main
}//end of TestWorkman