Question: Java Programing Language. please write your code in JAVA a. Create a class called Battery containing a battery number (as a unique identifier) of type
a. Create a class called Battery containing a battery number (as a unique identifier) of type int, a manufacturer of type String, and expiration date of type Date. Make it cloneable and implement its toString() method. b. Create a class called Toy that contains a name of type String, and an array of Battery and a toString() method that prints out info about all its batteries. Write a clone() for Toy that automatically clones its name and all of its Battery objects. c. Make sure that the clone() methods catch the CloneNotSupportedException rather than passing it to the caller, as shown in the Textbook. d. Write test methods only for the clone() methods that will do the cloning and print out the input parameter(s), expected results, and actual results. Choose 2-3 appropriate inputs to validate that they perform deep cloning (and not do shallow cloning.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
