抽象类PayCalulator -Code

时间:2013-10-30 01:42:25

标签: java abstract

创建一个抽象类PayCalculator,其中包含一个属性payRate 每小时美元。该类还应该有一个方法computePay(小时) 返回给定时间内的工资。

有人可以给我一个关于如何开始和完成此事的快速启动或抨击大纲吗?

编辑:到目前为止这是我的代码。

     package Main;

abstract class PayCalulator  {
    public static void main(String args[]){
     double payRate;
     int hoursWorked;
     int daysWorked;


     payRate = 12.75;
     hoursWorked = 14;
     daysWorked = 5;
     System.out.println("Here is your the break down of your pay in dollars is : " + hoursWorked * payRate);
     System.out.println("Total pay for a weeks worth of work is : " + hoursWorked * payRate * daysWorked);
     System.out.println("Please insert your hourly pay, how many hours you have worked and total pay expeted into the respective programming areas.");  

    }

}

1 个答案:

答案 0 :(得分:0)

在尝试此操作之前,您应该了解java中抽象类的含义。如果你不这样做,你可以在这里阅读:http://docs.oracle.com/javase/tutorial/java/IandI/abstract.html,但基本上代码看起来像这样:

public abstract class PayCalculator{
double payRate; //implement dollars per hour
abstract double computePay(int hours);
}

将来,在向Stackoverflow提供所有代码之前,我建议您先了解如何解决问题。