Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class MyDeque Type > - generic class declaration. public MyDeque ( ) - a constructor that initializes an empty MyDeque. public void addFirst (
public class MyDeque Type generic class declaration.
public MyDeque a constructor that initializes an empty MyDeque.
public void addFirstType item adds the item to the front of MyDeque.
public void addLastType item adds the item to the back of MyDeque.
public Type removeFirst removes and returns the item at the front of MyDeque or null
if MyDeque is empty
public Type removeLast removes and returns the item at the back of MyDeque or null
if MyDeque is empty
public Type peekFirst returns without removing the item at the front of MyDeque or
null if MyDeque is empty
public Type peekLast returns without removing the item at the back of MyDeque or
null if MyDeque is empty
public int size the current number of items in MyDeque.
public String toString converts the contents of MyDeque to a String for display.
The doublylinked node structure will be represented by the DLNode class, which must be local
to MyDeque hence only accessible by MyDeque and function according to the following
interface:
class DLNode local class declaration.
private DLNode next, prev forward and backward node pointers
DLNodeT item a constructor that creates a node containing the given item and points
forward and backward to null.
void linkDLNode next, DLNode prev links this DLNode forward and back the next
andor prev pointers can be null
The MyDeque and DLNode classes must not use or extend any other class except String and
possibly StringBuilder for creating a humanreadable display of the data structure, and
java.io
and System for the actual nor plain arrays. MyDeque and DLNode must be both built from
scratch and doublylinked allocation is required. Failure to do so will automatically award a
zero grade.
NB: The MyDeque class will be reused in later homework assignments design, implement and
test it carefully!
Your program will implement the Burger class using only the MyDeque class that must function
according to the following interface:
public class Burger plain class declaration.
Burgerboolean theWorks a constructor that initializes a Burger with only the buns and
patty if theWorks is false, or a Baron Burger if theWorks is true.
void changePattiesString pattyType changes all patties in the Burger to the pattyType.
void addPattyadds one patty to the Burger up to the maximum of
void addCategoryString type adds all items of the type to the Burger in the proper
locations.
void removeCategoryString type removes all items of the type from the Burger.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started