VL-Programmieren/VL13/Aufgabe01/Aufgabe01.java

80 lines
2.2 KiB
Java

package VL13.Aufgabe01;
import java.util.Stack;
/**
* Vorlesung 13 / Aufgabe 1
*
* @author Sebastian Brosch
*/
public class Aufgabe01 {
public static void main(String[] args) {
// Integer Stack
System.out.printf("\n%s:\n", "Integer Stack");
IntegerStack integerStack = new IntegerStack();
integerStack.push(7);
integerStack.push(3);
integerStack.push(8);
integerStack.push(2);
System.out.println(integerStack.pop());
System.out.println(integerStack.pop());
integerStack.push(7);
System.out.println(integerStack.pop());
System.out.println(integerStack.pop());
// Generic Stack (Integer)
System.out.printf("\n%s:\n", "Generic Stack (Integer)");
GenericStack<Integer> gIntegerStack = new GenericStack<Integer>();
gIntegerStack.push(7);
gIntegerStack.push(3);
gIntegerStack.push(8);
gIntegerStack.push(2);
System.out.println(gIntegerStack.pop());
System.out.println(gIntegerStack.pop());
gIntegerStack.push(7);
System.out.println(gIntegerStack.pop());
System.out.println(gIntegerStack.pop());
// Generic Stack (String)
System.out.printf("\n%s:\n", "Generic Stack (String)");
GenericStack<String> gStringStack = new GenericStack<String>();
gStringStack.push("Hallo");
gStringStack.push("Welt");
gStringStack.push("!");
System.out.println(gStringStack.pop());
System.out.println(gStringStack.pop());
System.out.println(gStringStack.pop());
// Stack (Integer)
System.out.printf("\n%s:\n", "Stack (Integer)");
Stack<Integer> nIntegerStack = new Stack<Integer>();
nIntegerStack.push(7);
nIntegerStack.push(3);
nIntegerStack.push(8);
nIntegerStack.push(2);
System.out.println(nIntegerStack.pop());
System.out.println(nIntegerStack.pop());
nIntegerStack.push(7);
System.out.println(nIntegerStack.pop());
System.out.println(nIntegerStack.pop());
// Stack (String)
System.out.printf("\n%s:\n", "Stack (String)");
Stack<String> stringStack = new Stack<String>();
stringStack.push("Hallo");
stringStack.push("Welt");
stringStack.push("!");
System.out.println(stringStack.pop());
System.out.println(stringStack.pop());
System.out.println(stringStack.pop());
}
}