Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java A dozen stack is a stack with a fixed size of 12 elements. If a dozen stack is full, then the element that

in java A dozen stack is a stack with a fixed size of 12 elements. If a dozen stack is full, then the element that has been on the stack, the longest, is removed to make room for a new new element. For this problem, you are required to design a class named DozenStack.java, which extends DozenStackAbstract.java, and implements push method to captures this specification of a dozen stack.

//the source code for DozenStackAbstract.java is provided for your reference (cant be changed)

public abstract class DozenStackAbstract{

private Character[] c; private int total; public DozenStackAbstract(){ c=new Character[12]; total=0; } public abstract void push(char c); public boolean isEmpty(){ return total==0; } public boolean isFull(){ return total==12; } public void pop(){ if(total>0) total--; } public Character top(){ if(total>0) return c[total-1]; else return null; } public void updateTotal(int num){ total +=num; } public Character[] getData(){ return c; } public int size(){ return total; }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions