Instructions
Requirements and Specifications
Source Code
STACK
public class A4Stack<T> implements Stack<T> {
private A4Node<T> head;
public A4Stack() {
head = null;
}
public void push (T value) {
A4Node<T> n = new A4Node<T>(value);
n.setNext(head);
head = n;
}
public T pop() {
T data = null;
if (isEmpty()) {
;
} else {
data = head.getData();
A4Node temp = head;
head = head.getNext();
temp.setNext(null);
}
return data;
}
public boolean isEmpty() {
if (head == null) {
return true;
}
return false;
}
public T top() {
T data = null;
if (isEmpty()) {
;
} else {
data = head.getData();
}
return data;
}
public void popAll() {
while (head != null) {
A4Node temp = head;
head = head.getNext();
temp.setNext(null);
}
}
}
PLATE
public class Plate {
private int diameter;
public Plate (int diameter) {
this.diameter = diameter;
}
public int getDiameter() {
return diameter;
}
public String toString() {
return Integer.toString(diameter);
}
}