Java Reference
In-Depth Information
public
PartTimeEmployee()
//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;
Figure 10-5 shows the UML class diagram of the
class
PartTimeEmployee
and the
inheritance hierarchy.
PartTimeEmployee
-payRate:
double
-hoursWorked:
double
+PartTimeEmployee()
+PartTimeEmployee(String, String,
double
,
double
)
+toString(): String
+setNameRateHours(String, String,
double
,
double
):
void
+getPayRate():
double
+getHoursWorked():
double
+calculatePay():
double
Person
PartTimeEmployee
FIGURE 10-5
UML class diagram of the
class
PartTimeEmployee
and the inheritance hierarchy
The definitions of the member methods of the
class
PartTimeEmployee
are as follows:
public
String toString()
{
return
(
super
.toString() + "\'s wages are: $" + calculatePay());
}
public double
getPayRate()
{
return
payRate;
}
public double
getHoursWorked()
{
return
hoursWorked;
}
public double
calculatePay()
{
return
(payRate * hoursWorked);
}
Search WWH ::
Custom Search