CS计算机代考程序代写 package linear;

package linear;

public class StackUsingLinkedList {

private LinkedList list = new LinkedList();

public void push(T v) {
list.addFront(v);
}

public T peek() {
return list.getFront();
}

public T pop() {
return list.deleteFront();
}

public boolean isEmpty() {
return list.isEmpty();
}

public static void main(String[] args) {
StackUsingLinkedList stack = new StackUsingLinkedList();
//stack.pop(); // an exception is triggered
stack.push(“CS112″);
stack.push(” “);
stack.push(“to”);
stack.push(” “);
stack.push(“Welcome”);
while (!stack.isEmpty()) {
System.out.print(stack.pop()); //Welcome to CS112
}
}
}