Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Deque JAVA

luckens-victor
luckens-victor 


Assign date: 9/24/15 Due date: 10/9/15 1.Create a MyDeque class based on the discussion of deques (p. 143) in this chapter. It should include the following methods: insertFront() insertRear() removeFront() removeRear() peekFront() peekRear() isEmpty() isFull() toString() Peek means retrieve the value without remove it. •You may create the class by updating the existing class Queue.java in page 138 of the textbook. Delete display () method from the class. •The data type of the elements in MyDeque is DataRecord. DataRecord class contains: o Instance vars: id (String: any numeric chars) and data (String: any string). o Set/get methods, toString() o Use default constructor when create the object (you don’t need to write the constructor) •It needs to handle wrap-around of the array, as a circular queue does. •Refer the given methods in the example class to define the signature (method head) of each above method. 2.The toString() in MyDeque should always display the data stored in the deque in the sequence from ‘front’ to ‘rear’, not the data sequence from index 0 to the end in the array. 3.Write an application class to test all methods defined in MyDeque class. The application should allow the user to decide the length of the deque and operate on the queue as many times as he/she wants till choosing ‘Quit’. The selections for users are: • Insert to front • Insert to rear • Remove from front • Remove from rear • Peek front • Peek rear • Display queue • Quit You should test the functions as thoroughly as you can. Test the deque with the size of 5. Make the cases to allow the front and rear crossing the array boundaries in both ends. You have to record your testing sample and submit it with all classes. In the record, show me how you test the front/rear crossing low index boundary and high index boundary. (Display your deque frequently during the debugging to check the correctness of the functions) 4.Write a program to implement a stack class which is based on the Deque class you have implemented. It should include the following methods: push() pop() peek() isEmpty() isFull() To avoid the name conflict with the Stack class defined in Java library, please pick any name other than Stack for your class. [Note: This technique is called delegation. Define a deque object in this stack class, and then use any existing methods of the deque to implement the functions of the stack. If you still have problems, do self-study for class delegation in OO design.] 5.For all methods and applications you write, give comments (top doc before each method, not only // comments by the side of the sentences) to explain your strategy. 6.Make all screen-output meaningful to the user. 7.Submission: •DeQue class •DeQueApp class •MyStack class (Can use any name you want except Stack. Must be implemented by using your DeQue class. ) •Test sample data and the sequence of operations Note: No MyStackAPP required THIS IS THE ASSIGNMENT GIVEN TO ME FOR HW. I WILL UPLOAD THE "QUEUE.JAVA" FILE AS A .TXT FILE. Attachments Tags
Clarifications

Answers

Advance pay

sudheer488
sudheer488 



Advance pay Attachments
Screenshots
Purchase Answer

mydeque class

felo
felo 



MyDeque class Attachments
MyDeque.rar (2 K) Download





Preview
Item {

Preview
return queArray[front]; } public Item peekRear() //peek at last of queue { return queArray[rear]; } public boolean isEmpty() //true if queue is empty { return(nItems == 0); } public boolean isFull() //true if queue is full { return(nItems

Screenshots
Purchase Answer

Deque Java Program

sudheer488
sudheer488 



Complete program & Document with Screenshot also attached. Attachments
DeQueue screen shots.docx (1321 K) Download
Program.zip (9 K) Download






Preview
queue } catch(Exception e) { System.out.println("Error : " +e.getMessage()); } break; case 6 : try { System.out.println("Peek Element = "+q.peekRear());//peek elements from the rear side of queue } catch(Exception e) { System.out.println("Error : "+e.getMessage()); }

Preview
accept the size of an array */ public void SizeofArray(int n) { size = n; len = 0; Queue = new String[size]; Queue1=new String[size]; front = -1; rear = -1; } /* Function to check if queue is empty */

Preview
System.out.println("Enter an element to insert"); try { q.insert( scan.next() );//calling mydeque insert method to insert stack elements } catch(Exception e) { System.out.println("Error : " +e.getMessage()); } break; case 2: try { System.out.println("Removed Element = "+q.remove());//calling mydeque

Screenshots
Purchase Answer

Mr.

felo
felo 



1 Attachments
Screenshots
Purchase Answer