/* CourseListProgram.java by Craig Persiko for CS 111A example
   Shows how to build and use an ArrayList of Course objects
*/

import java.util.ArrayList;

public class CourseListProgram
{
  public static void main(String[] args)
  {
    ArrayList<Course> courses = new ArrayList<Course>();
    Course c;
    int count;

    c = new Course("MATH", "110A", "Calculus");
    courses.add(c);

    courses.add(new Course("CS", "111A", "Intro to Programming Java"));
    courses.add(new Course("CS", "160A", "Intro to UNIX/Linux"));

    //insert CS 160B into position 1 of list:
    courses.add(1, new Course("CS", "160B", "Unix/Linux Shell Scripting"));

    for(Course cc : courses)
      cc.printCourse();

    // remove item number 2 (CS 111A) from list:
    courses.remove(2);

    count = courses.size();
    System.out.println("After removing number 2, there are now " + count + " courses in the list:");

    for(int i=0; i < count; i++)
    {
      c = courses.get(i);
      c.printCourse();
    }

  }
}

/* Output:

[cpersiko@milhouse ~]$ java CourseListProgram
MATH110A: Calculus
CS160B: Unix/Linux Shell Scripting
CS111A: Intro to Programming Java
CS160A: Intro to UNIX/Linux
After removing number 2, there are now 3 courses in the list:
MATH110A: Calculus
CS160B: Unix/Linux Shell Scripting
CS160A: Intro to UNIX/Linux
[cpersiko@milhouse ~]$ 

*/



syntax highlighted by Code2HTML, v. 0.9