Wrappershallow and wrapperdeep

Assignment Help JAVA Programming
Reference no: EM13158972

Make 2 classes WrapperShallow and WrapperDeep. Each class is simply a wrapper class to hold a private array variable. int [] a; The default constructor for each class should initialize â??aâ??. Each class should have a toString() and equals(). Each class should have a setArray method that allows you to set the â??aâ?? variable. WrapperShallow should have an invalid copy constructor. public WrapperShallow(WrapperShallow ws){ a = ws.a; } WrapperDeep should have a properly functioning copy constructor. public WrapperDeep(WrapperDeep ws){ a = new int[3]; for(int i = 0; i < 3; i++) a[i]=ws.a[i]; } Think about why shallow is wrong and deep is correct! What happens to the old â??aâ?? in the WrapperDeep copy constructor? (think garbage collection) Example Output: --------------------Configuration: -------------------- **** TESTING SHALLOW OBJECTS **** inital shallow object contains 7 17 77 copy shallow object contains 7 17 77 inital shallow object changed to 13 14 15 copy shallow object not changed contains 13 14 15 WOOPS! ws.equals(ws2) is true **** TESTING DEEP OBJECTS **** inital deep object contains 2 3 4 copy deep object contains 2 3 4 inital deep object changed to 7 6 -5 copy deep object not changed contains 2 3 4 RIGHT! wd.equals(wd2) is false Process completed.

Reference no: EM13158972

Questions Cloud

Different types of physical evidence : Name a few different types of physical evidence that can be used by an investigator to help link the suspect to a victim or crime scene
Compute the predetermined overhead rate : Calculate the predetermined overhead rate for 2010, assuming Garcia Manufacturing estimates total manufacturing overhead costs of $1,050,000, direct labor costs of $700,000 and direct labor hours of 20,000 for the year.
Discribe the economic profit : Discribe the difference in economic profit between a competitive firm and a monopolist in both athe short and long run. Which should take longer to reach the long-run equilibrium?
Which population of vesicles has a surface similar to cell : Your friend has isolated plasma membranes and reassembled the membranes into small vesicles. Using fluorescently labeled lectin, he sees that some of his vesicles are labeled while others are not.
Wrappershallow and wrapperdeep : Each class is simply a wrapper class to hold a private array variable. int [] a; The default constructor for each class should initialize â??aâ??. Each class should have a toString() and equals(). Each class should have a setArray method that allows ..
Describe stock solution of nacl : Describe how you would prepare 500mL of a single solution containing 250mM Tris, 50mM glucose, and 5mM NaCl.
What attributes of these variables make them discrete : Provide some examples of discrete and continuous variables. What attributes of these variables make them discrete and continuous? Why?
Study and understanding of public policy : Identify two or three academic disciplines, other than political science, that contributes to the study and understanding of public policy. Explain their contribution.
Critically examine the impact of wto on us industry : Critically examine the impact of WTO on US industry since its inception?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd