import java.rmi.*;
import java.rmi.server.*;
import java.util.*;

/**
 * The implementation of a database of Course objects
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0rmi
 */
public class CourseDatabaseImpl extends    UnicastRemoteObject
                                implements CourseDatabase
{
    private Hashtable      db;

    /**
     * Constructor
     */
    public CourseDatabaseImpl() throws RemoteException
    {
	db = new Hashtable();
    }

    /**
     * Add a Course
     *
     * @param course   The Course to add
     */
    public void add(Course course)  throws RemoteException
    {
	db.put(course.getDesignation(), course);
    }

    /**
     * Get a Course
     *
     * @param course   The Course to get
     */
    public Course get(String department, int number)  throws RemoteException
    {
	return (Course)db.get(department+number);
    }

    /**
     * Remove a Course
     *
     * @param department   The department code
     * @param number       The course number
     */
    public void remove(String department, int number)  throws RemoteException
    {
	db.remove(department+number);
    }
}
