Question: Please write the following methods in Java, thank you. public MyDeque(MyDeque old) public boolean equals(MyDeque rhs) public String toString() The first method is a copy

Please write the following methods in Java, thank you.

 public MyDeque(MyDeque old) public boolean equals(MyDeque rhs) public String toString() 

The first method is a copy constructor, which should make a new MyDeque that is logically equivalent to the argument. The copy constructor should not be shallow the arrays should not be shared. However, it does not have to be completely deep either (you don't need to make new copies of the individual items in the deque). Note also that the copy does not have to have the same values for front and back as the original the important thing is that both contain the same data in the same relative ordering from front to back.

The second method is an equals method that returns true if the deques are logically equivalent. In this case logically equivalent means that the individual items in both deques are equal() and in the same relative positions within the deques (based on front and back). However, they do not have to be located in the same index values in the arrays.

The third method is a toString() method which will make a and return single String of all the data in the MyDeque from front to back and return it. This method will assume that a reasonable toString() method exists for whatever type T is being used for the MyDeque.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!