/ Is my code correct? //please make it more efficient as you can. Thank you //please correct it if there is some mistakes

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question
100%

// Is my code correct?

//please make it more efficient as you can. Thank you

//please correct it if there is some mistakes

public class PartTimeEmployee extends Person

{

    //private variables

    private double payRate;

    private double hoursWorked;

    public PartTimeEmployee()

    {

        super();

        /*invokes the default constructor of class Person

        */

        payRate = 0;

        hoursWorked = 0;

    }

    public PartTimeEmployee(String idPerson, String nameFirst, String nameLast,

    String date, String addressPerson, double pay, double hours)

    {

        super(idPerson, nameFirst, nameLast, date, addressPerson);

        /*invokes the non-default constructor

          in other words, override the parameters from Person() non-defaukt

          with another set of parameters, example 'idPerson' variable

          overrides 'id' in Person()

        */

        this.payRate = pay;

        this.hoursWorked = hours;

    }

    public String toString(String idPerson, String nameFirst, String nameLast,

    String date, String addressPerson)

    {

        return idPerson+nameFirst+nameLast+date+addressPerson;

        //not sure about this one, please check

    }

    public double getPayRate(){return payRate;} 

    public double getHoursWorked(){return hoursWorked;}

    public void setNameRateHours(String idPerson, String nameFirst, String nameLast,

    String date, String addressPerson, double pay, double hours)

    {

        super.setPerson(idPerson, nameFirst, nameLast, date, addressPerson);

        this.payRate = pay;

        this.hoursWorked = hours;

        //not sure about this, please check

    }

    public double calculatePay(){return (payRate*hoursWorked);}

    //this one , calculatePay, not sure if this is the correct formula xD

 

PartTimeEmployee
|-payRate: double
-hoursWorked: double
+PartTimeEmployee ()
+PartTimeEmployee (String, String,
double, double)
Person
+tostring () : String
+setNameRateHours (String, String,
double, double): void
+get PayRate ((): double
+getHoursWorked (): double
+calculatePay () : double
PartTimeEmployee
FIGURE 11-5 UML class diagram of the class PartTimeEmployee and the inheritance hierarchy
Transcribed Image Text:PartTimeEmployee |-payRate: double -hoursWorked: double +PartTimeEmployee () +PartTimeEmployee (String, String, double, double) Person +tostring () : String +setNameRateHours (String, String, double, double): void +get PayRate ((): double +getHoursWorked (): double +calculatePay () : double PartTimeEmployee FIGURE 11-5 UML class diagram of the class PartTimeEmployee and the inheritance hierarchy
Expert Solution
steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT