Answered step by step
Verified Expert Solution
Link Copied!

Question

00
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.
please write your code in JAVA
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions