
// This is a very simple stub for a course inventory, based on
// dialog boxes. It displays the parameters passed, and
// allows a response to be chosen.

import javax.swing.*;
import java.awt.*;

public class CourseInventory {

  public CourseInventory() {}

  // This stub method displays the parameters and returns nothing
  // or throws an exception based on what is chosen.

  public void addStudent(int coursecode, String name) {

    // Display parameters
    String display = "addStudent called with " + coursecode + " and " + name
                   + "\nShould addStudent:"
                   + "\n1) return nothing (success)"
                   + "\n2) throw a CourseClosedException"
                   + "\n3) throw a NoSuchCourseException";

    String reply = JOptionPane.showInputDialog(null, display);

    if (reply.equals("1")) return;
    if (reply.equals("2")) throw new CourseClosedException();
    if (reply.equals("3")) throw new NoSuchCourseException();
    }

  }



