Program 1 Assigned date: September 23, 2003 Due date: September 30, 2003 (@5:30 p.m.) Delivery mechanism: hard copy (compiled .java source code + output of program) Grade: 50 points on time or 25 points for late. please check the following on my web site: For this assignment, you will implement java.util.Enumeration several different ways. Here is the puzzle (NOTE: YOUR PROGRAM MUST WORK FOR ANY List). ---------------- import java.util.*; public class MyClass { private List list = null; public MyClass(int size) { list = new ArrayList(); for (int i=0; i < size; i++) { list.add(new Integer(i)); } } public Enumeration forward() { //will enumerate array elements from index 0 to (size-1) } public Enumeration backward() { //will enumerate array elements from index (size-1) to 0 } public Enumeration any() { //will enumerate array elements in any random order } public Enumeration even() { //will enumerate even indexed array elements // even indexes are: 0, 2, 4, ... } public Enumeration odd() { //will enumerate odd indexed array elements // even indexes are: 1, 3, 5, ... } // inner classes for implementing forward(), backward(), // random(), even(), and odd() methods } /** * driver class */ public class TestMyClass { public static void main(String[] args) throws Exception { int size = Integer.parseInt(args[0]); // // test forward() // MyClass mine = new MyClass(size); Enumeration forward = mine.forward(); while (forward.hasMoreElements()) { Integer i = (Integer) forward.nextElement(); System.out.print("\t\t"+i); } System.out.print(" -------"); // // test backward() // MyClass mine2 = new MyClass(size); Enumeration backward = mine2.backward(); while (backward.hasMoreElements()) { Integer i = (Integer) backward.nextElement(); System.out.print("\t\t"+i); } System.out.print(" -------"); // // test any() // MyClass mine3 = new MyClass(size); Enumeration any = mine3.any(); while (any.hasMoreElements()) { Integer i = (Integer) any.nextElement(); System.out.print("\t\t"+i); } System.out.print(" -------"); // // test even() // MyClass mine4 = new MyClass(size); Enumeration even = mine4.any(); while (even.hasMoreElements()) { Integer i = (Integer) even.nextElement(); System.out.print("\t\t"+i); } System.out.print(" -------"); // // test odd() // MyClass mine5 = new MyClass(size); Enumeration odd = mine5.odd(); while (odd.hasMoreElements()) { Integer i = (Integer) odd.nextElement(); System.out.print("\t\t"+i); } System.out.print(" -------"); } }