Java Reference
In-Depth Information
public void
setNameRateHours(String first, String last,
double
rate,
double
hours)
{
setName(first, last);
payRate = rate;
hoursWorked = hours;
}
The definition of the constructor with parameters is as follows. (Note that the body
contains a call to the superclass's constructor with parameters.)
public
PartTimeEmployee(String first, String last,
double
rate,
double
hours)
{
super
(first, last);
payRate = rate;
hoursWorked = hours;
}
The definition of the default constructor is:
public
PartTimeEmployee()
{
super
();
payRate = 0;
hoursWorked = 0;
}
The definition of the
class
PartTimeEmployee
is:
public class
PartTimeEmployee
extends
Person
{
private double
payRate;
//store the pay rate
private double
hoursWorked;
//store the hours worked
1
0
//Default constructor
//Set the first name, last name, payRate, and
//hoursWorked to the default values.
//The first name and last name are initialized to an empty
//string by the default constructor of the superclass.
//Postcondition: firstName = ""; lastName = "";
// payRate = 0; hoursWorked = 0;
public
PartTimeEmployee()
{
super
();
payRate = 0;
hoursWorked = 0;
}
//Constructor with parameters
//Set the first name, last name, payRate, and
//hoursWorked according to the parameters.
//Parameters first and last are passed to the
//superclass.
Search WWH ::
Custom Search