// This class is one currently being developed with the help
// of driver and stub classes. Users can add classes to a list.

public class Student {

  private String name;
  private int[] courses;
  private int numCourses;
  private CourseInventory inventory; // Course inventory object (currently stub)

  public Student(String n) {
    name = n;
    courses = new int[20];
    numCourses = 0;
    }

  public void addCourse(int coursecode)
    throws AlreadyInCourseException,
           CourseClosedException,
           NoSuchCourseException {

    // Check whether already in this course (can do here).
    for (int i = 0; i < numCourses; i++)
      if (courses[i] == coursecode)
        throw new AlreadyInCourseException();

    // Try adding course to course inventory.
    // For now, this will involve calling a stub method.
    inventory.addStudent(coursecode, name);

    // If successful, add to list.
    courses[numCourses] = coursecode;
    numCourses++;
    }

  public void setInventory(CourseInventory i) {
    inventory = i;
    }

  // This tool returns all data about current state of object
  public String inspect() {  
    String reply = "Name: " + name + "\nNumber of courses: " + numCourses;
    for (int i = 0; i < numCourses; i++) reply = reply + "\n" + courses[i];
    return reply;
    }

  }
    

