Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Java Programing Language
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.) Please write your code in JAVA
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started