public class Todo { // main method: test our todo class public static void main(String a[]) { Todo t = new Todo(); // [] t.push("prepare English exam"); // ["prepare"] t.push("try to do Programming exercises"); // ["prepare", "try"] t.push("call my brother"); // ["prepare", "try","call"] System.out.println(t.pop()); // ["try","call"] t.pop(); // ["call"] System.out.println(t.getCount()); // ["call"] t.push("sleep"); // ["call", "sleep"] System.out.println(t.pop()); // ["sleep"] } // attributes private String[] item; private int count; // methods public Todo(){ item = new String[100]; count = 0; } public void push(String j) { item[count] = j; count++; } public String pop() { String tmp = item[0]; // shift each element down by one position int k; for (k = 0; k <= count-1; k++){ item[k] = item [k+1]; } count--; return tmp; } public int getCount() { return count; } }