Java Reference
In-Depth Information
Self-Test Exercises
(continued)
14. Modify the following class definition so it correctly implements the
Cloneable
interface (all the new instance variables are shown):
public class
PricedItem
extends
StockItem
{
private double
price;
...
}
15. Modify the following class definition so it correctly implements the
Cloneable
interface (all the instance variables are shown):
public class
Record
{
private
StockItem item1;
private
StockItem item2;
private
String description;
...
}
16. Modify the following class definition so it correctly implements the
Cloneable
interface (all the new instance variables are shown):
public class
BigRecord
extends
Record
{
private
StockItem item3;
...
}
17. Modify the definition of the class
Date
(Display 4.13) so it implements
the
Cloneable
interface. Be sure to define the method
clone
in the style of
Display 13.7.
18. Modify the definition of the class
Employee
(Display 7.2) so it implements
the
Cloneable
interface. Be sure to define the method
clone
in the style of
Display 13.8.
19. Modify the definition of the class
HourlyEmployee
(Display 7.3) so it imple-
ments the
Cloneable
interface. Be sure to define the method
clone
in the style of
Display 13.8.