Starting from:

$12

Wrapper Shallow and Wrapper Deep

Make 2 classes Wrapper Shallow and Wrapper Deep.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;}Wrapper Deep 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];}Example Output:---------------------------------Configuration: --------------------------------------**** TESTING SHALLOW OBJECTS ****initial shallow object contains
7 17 77
copy shallow object contains
7 17 77
initial 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 ****initial deep object contains
2 3 4
copy deep object contains
2 3 4
initial deep object changed to
7 6 -5
copy deep object not changed contains
2 3 4
RIGHT! wd.equals (wd2) is falseProcess completed.
0

More products