HW #2 CODE FILE (UPDATED)
REMEMBER, DON’T CHANGE ANY GIVEN CODE UNLESS SPECIFIED!IF YOU WANT TO ADD ANTHING ELSE, YOU MUST ASK THE INSTRUCTOR FIRST OR YOU MAY GET POINTS OFF!
in the LinkedQueue and ArrayQueue classes add and complete the equals method as described below:
@Override
public equals( Object obj )
in LinkedQueue:
compare corresponding elements in this’ list to the parameter’s list ONLY IF THE PARAMETER IS AN INSTANCEOF LinkedQueue (best to check if the sizes are the same first).DON’T CHANGE ANYTHING in either LinkedQueue, so don’t call dequeue nor enqueue OR POINTS OFF!Make sure you compare the data (T) using its equals method!
in ArrayQueue:
compare elements in this’ array to the parameter’s array ONLY IF THE PARAMETER IS AN INSTANCEOF ArrayQueue (make sure STARTING AT THE FRONT OF THE this’ queue array AND the FRONT OF THE PARAMETER’S queue array (they don’t have to have the same front index to be equal).DON’T CHANGE ANYTHING in either ArrayQueue, so don’t call dequeue nor enqueue OR POINTS OFF. Make sure you compare the data (T) using its equals method!
// you MUST call this method at the end of main
//put this method in the driver class exactly as it’s written
// (must not change it):
public static void extraQueueTester()
{
LinkedQueue<Double> doubQueue = new LinkedQueue<>();
doubQueue.enqueue(new Double(1.2));
doubQueue.enqueue(new Double(8.9));
System.out.println(“nTesting Double LinkedQueue: “);
System.out.println(“Testing dequeuing Double LinkedQueue: ” + doubQueue.dequeue());
System.out.println(“Testing dequeuing Double LinkedQueue: ” + doubQueue.dequeue());
System.out.println(“Double LinkedQueue’s size is ” + doubQueue.size());
System.out.println(“Testing equals for empty LinkedQueues returns “+
doubQueue.equals(new LinkedQueue<Double>()));
System.out.println(“Testing enqueuing Double LinkedQueue after emptying: ” +
doubQueue.enqueue(new Double(3.4)) );
System.out.println(“Double LinkedQueue’s size is now ” + doubQueue.size());
System.out.println(“nTesting Double ArrayQueue: “);
ArrayQueue<Double> doubQueue2 = new ArrayQueue<>();
for( int i = 0; i < 14 ; ++i )
{
if(doubQueue2.enqueue(100.+i)) // uses autoboxing
System.out.println(“Successfully enqueued ” + (100.+i));
else
{
System.out.println(“Unable to enqueue “+(100.+i));
System.out.println(“Dequeuing ” + doubQueue2.dequeue());
doubQueue2.enqueue(100.+i);
}
System.out.println(“ArrayQueue size is ” + doubQueue2.size());
}
System.out.println(“Testing emptying the ArrayQueue:”);
while( !doubQueue2.isEmpty() )
System.out.println(“Dequeuing ” + doubQueue2.dequeue() +
” size is now ” + doubQueue2.size());
System.out.println(“Testing equals for empty ArrayQueues returns “+
doubQueue2.equals(new ArrayQueue<Double>()));
System.out.println(“Testing enqueuing Double ArrayQueue after emptying: ” +
doubQueue2.enqueue(18.0) );
System.out.println(“Double ArrayQueue now has: ” + doubQueue2.peekFront());
System.out.println(“Double ArrayQueue’s size is ” + doubQueue2.size());
} // end extraQueueTester
 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount! Use Discount Code “Newclient” for a 15% Discount!NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.

The post java-programming-question-using-data-structures-1 appeared first on Essay Fount.


What Students Are Saying About Us

.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐
"Honestly, I was afraid to send my paper to you, but you proved you are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"

.......... Customer ID: 11***| Rating: ⭐⭐⭐⭐⭐
"This company is the best there is. They saved me so many times, I cannot even keep count. Now I recommend it to all my friends, and none of them have complained about it. The writers here are excellent."


"Order a custom Paper on Similar Assignment at essayfount.com! No Plagiarism! Enjoy 20% Discount!"