package net.megaroid.collections;

import java.util.Scanner;

public class TestStack {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String cmd = "";
		Stack<Integer> stack = new Stack<Integer>();
		
		System.out.println("Input a command('push', 'pop', 'print', 'quit')");
		
		while (!cmd.equals("quit")) {
			System.out.print("> ");
			cmd = scanner.next();
			
			if (cmd.equals("push")) {
				System.out.print("Input a number: ");
				int num = scanner.nextInt();
				stack.push(num);
			} else if (cmd.equals("pop")) {
				int num = stack.pop();
				System.out.println("Pop a number: " + num);
			} else if (cmd.equals("print")) {
				System.out.println("STACK:" + stack);
			} else if (cmd.equals("quit")) {
				break;
			} else {
				System.err.println("Unknown command '" + cmd + "'");
			}
		}
		
		scanner.close();
	}
	
}

@@ -53,16 +53,51 @@
 Scanner;
+%0Aimport net.megaroid.math.Rational;
 %0A%0Apublic
@@ -229,23 +229,24 @@
 %09%09Stack%3C
-Integer
+Rational
 %3E stack 
@@ -261,19 +261,13 @@
 ack%3C
-Integer
 %3E();
+ 
 %0A%09%09%0A
@@ -487,24 +487,37 @@
 (%22Input 
-a
+two
  number
+s ( n / m )
 : %22);%0A%09%09
@@ -519,25 +519,54 @@
 );%0A%09%09%09%09int n
-u
+ = scanner.nextInt();%0A%09%09%09%09int 
 m = scanner.
@@ -592,18 +592,33 @@
 k.push(n
-um
+ew Rational(n, m)
 );%0A%09%09%09%7D 
@@ -651,19 +651,24 @@
 ) %7B%0A%09%09%09%09
-int
+Rational
  num = s

Test Stack<Rational>