Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.EmptyStackException; / / import java.util.Stack; public class A 3 Stack implements Stack { private A 3 bNode head; / / Do NOT add any

import java.util.EmptyStackException;
//import java.util.Stack;
public class A3Stack implements Stack {
private A3bNode head;
// Do NOT add any other fields to this class.
// You should be able to implement the Stack
// interface with just a head field.
public A3Stack(){
head = null;
}
public void push(T value){
A3bNode newNode = new A3bNode<>(value);
newNode.next = head;
head = newNode;
}
public T pop(){
A3bNode temp = head;
head = head.next;
return temp.getData();
}
public void popAll(){
head = null;
}
public void makeEmpty(){
head = null;
}
public boolean isEmpty(){
return (head == null);
}
public T peek(){
return head.getData();
}
public int size(){
int count =0;
A3bNode curr = head;
while (curr != null){
count++;
curr = curr.next;
}
return count;
}
// Implemented for you for debugging purposes
public String toString(){
String result ="{";
String separator ="";
A3bNode cur = head;
while (cur != null){
result += separator + cur.getData().toString();
separator =",";
cur = cur.next;
}
result +="}";
return result;
}
}
Is recieving this error: error: type Stack does not take parameters
public class A3Stack implements Stack {
^
1 error

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_2

Step: 3

blur-text-image_3

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

Cite ways to overcome fear of success.

Answered: 1 week ago