Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Microsoft Office 365 For Beginners 2022 8 In 1

Authors: James Holler

1st Edition

B0B2WRC1RX, 979-8833565759

More Books

Students also viewed these Databases questions