Question: In java programming language, i have attached two files (Program3.java and MyClass.java) also a screenshot of sample execution. Any help is appreciated thanks!! The extra
HOMEWORK GOAL This is an individual homework grade. The assignment is to add a clone operation and a copy constructor to a class that has mutable instance variables in it. PROGRAM REQUIREMENTS I have posted a small program (Program3.java and MyClass.java) along with this assignment file on canvas, in the Assignments Directory. Add clone and a copy constructor to MyClass.java (don't forget to put your name in the comments). Add code to Program 3 to test your operations and make sure you are getting independent object data after the copies happen. ADDITIONAL INFORMATION TO TURN IN Turn in your versions of Program3.java and MyClass.java to canvas by the due date. Also, use this exercise to think about using gets/sets with classes like this What could happen to the state of an object if you were provide a get that simply returns a reference to the numbers instance variable? How would you handle it if you were using data types in your class that also contain internal mutable data? How do you ensure that those instances are handled properly. What if I wanted to pass in mutable objects into set methods? When Is it okay? When do I need to make a copy? What information should I put in my documentation for the users of my class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
