
import java.util.Scanner; public class Bill {
public static final double RATE=150.0; 这里没有创建getter和setter方法,直接创建了一个方法体为参数接收参数值,
private int hours;
private int minutes;
private double fee; public void inputTimeWorked() {
System.out.println("Enther");
System.out.println("followedr");
Scanner Keyboard =new Scanner(System.in);
hours=Keyboard.nextInt();
minutes=Keyboard.nextInt();
}
private double computeFee(int hoursWorked,int minutesWorked) {
minutesWorked=hoursWorked*60+minutesWorked;
int quarterHours=minutesWorked/15;
return quarterHours*RATE;
}
public void updateFee() { 这里调用updateFee方法 这里的hours和minutes是当前类的变量
fee=computeFee(hours,minutes);
}
public void outputBill() {
System.out.println("time worked:");
System.out.println(hours+"hours and"+minutes+"minutes");
System.out.println("rate"+RATE+"per quarter hour");
System.out.println("amout due"+fee);
}
public static void main(String[] args) {
System.out.println("welcome to:");
System.out.println("Deway:");
Bill yourBill=new Bill();
yourBill.inputTimeWorked();
//yourBill.updateFee();
yourBill.outputBill();
System.out.println("we have:");
System.out.println("it has:"); } }