Java Reference
In-Depth Information
SalariedEmployee otherSalariedEmployee =
(SalariedEmployee)otherObject;
return ( super .equals(otherSalariedEmployee)
&& (salary == otherSalariedEmployee.salary));
}
}
21. A version of the Date class with this definition of equals is in the subdirectory
improvedEquals of the ch07 directory on the accompanying website.
extra code
on website
public boolean equals(Object otherObject)
{
if (otherObject == null )
return false;
else if (getClass() != otherObject.getClass())
return false ;
else
{
Date otherDate =
(Date)otherObject;
return ( month.equals(otherDate.month)
&& (day == otherDate.day)
&& (year == otherDate.year) );
}
}
22. Not the same class .
23. The following is included in the definition of EnhancedStringTokenizer on the
accompanying website .
extra code
on website
public Object nextElement()
{
String token = super .nextToken();
a[count] = token;
count++;
return (Object)token;
}
Programming Projects
Visit www.myprogramminglab.com to complete select exercises online and get instant
feedback.
1. Define a class named Payment that contains an instance variable of type double
that stores the amount of the payment and appropriate accessor and mutator
methods. Also create a method named paymentDetails that outputs an English
sentence to describe the amount of the payment.
 
Search WWH ::




Custom Search