Hi everyone I am trying to get this done and it is not happening :to implement the method for the is Empty and is Full. I am suppose to check for an empty stack and check for a full stack
But I am not getting it? Can someone see something I am not seeing:
Basic data structure to provide LIFO (last-in-first-out) functionality
class SimpleStack {
private int top;
private int stackSize;
private char []buffer;
// Your default constructor
SimpleStack() {
top = -1; // Set top of the stack to -1 to indicate an empty stack
stackSize = 5; // Set the default size of the stack to 5
buffer = new char[5]; // Buffer (container) to hold items
}
// Your parameterized (convinient) constructor
SimpleStack(int size) {
top = -1;
stackSize = size;
}
// push method to place an item on top of the stack
public void push(char item) {
buffer[++top] = item;
}
// pop method to return the item on top of the stack
public char pop() {
return buffer[top--];
}
// Checks to see if the stack is empty
drinkgoodjava: public boolean isEmpty() {
// Logic: Stack is empty if top has reached -1.
// This method should return "true" if stack is empty and "false" otherwise.
// Note that you need to write the code in here.
}
// Checks to see if the stack is full
public boolean isFull() {
// Logic: Stack is full if "top" has reached stackSize - 1
// This method should return "true" if stack is full and "false" otherwise.
// Note that you need to write the code in here.
}
}
// Checks to see if the stack is full
public boolean isFull() {
// Logic: Stack is
WHAT AM I MISSING HERE??????