Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description : Your objective is to implement a stack and a queue using the list implementation you did in assignment #3. You must use the

Description: Your objective is to implement a stack and a queue using the list implementation you did in assignment #3. You must use the linked list implementation of a list. You are to use your list operations to accomplish the operations of a stack and queue. Getting started: Grab your ListAsLinkedList class and your Node class from assignment #3 In the List.java file given to you, where it says "public class List", put your ListAsLinkedList class's fields and methods. To be clear, this creates a new class called List (that does NOT implement IList) that is the exact same as your ListAsLinkedList class. DON'T FORGET to rename the constructor to "List". Where it says "class Node", put your Node class's fields and methods. You will not need the IList interface nor the ListAsArray class, so do NOT include them. The Stack.java and Queue.java files given to you are where you will implement your stack and queue. They have been "stubbed out" meaning method "stubs", or blank methods, have been created for you. These need to be given an implementation that will carry out the operations. Running the code: The Main.java file contains the entry point, so compiling and running that class will run the application. The undo command in the game relies on a correct stack implementation and the replay command relies on a correct queue implementation. Testing these two commands will test your stack and queue implementations and ensure they are functioning correctly. ADD GENERICS!!

QUEUE CODE

/** Queue abstract data type */ public class Queue { /** List objects to hold our queue items. Use List operations to implement the methods below */ private List list; public Queue() { // instantiate list here } public void enqueue(char value) { } public char dequeue() { } public char front() { } public boolean isEmpty() { } }

STACK CODE

/** Stack abstract data type */ public class Stack { /** List objects to hold our stack items. Use List operations to implement the methods below */ private List list; public Stack() { // instantiate list here } public void push(char value) { } public char pop() { NECCESARY CODE FROM ASSIGNMENT 3 
/** Linked List implementation of our List abstract data type */ public class List { // put all fields from ListAsLinkedList class here class ListAsLinkedList implements IList { /** * references to head and tail nodes of this list */ private Node head, tail; /** * count of current number of elements in this list */ private int count; //constructor initializing empty list public ListAsLinkedList() { head=null; tail=null; count=0; } 

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions