Homework 3

Assigned 9 Feb, due 26 Feb.

To get a feel for object-oriented programming in CLOS, we'll write a simple database package that records information about students and the courses they're taking.

Every student has a name (stored as a string), an academic level (one of the symbols 'freshman, 'sophomore, 'junior, 'senior, or 'graduate), and a list of courses.
Every course has a name and a professor, who is a person but not necessarily a student.

The following functions represent the user interface to the program.

(make-person ['name "person's name"])
creates a new person, with initial status as specified by the optional arguments, and returns the person object. For example,
(make-person 'name "Bloch") would return a person with name "Bloch".
(make-student ['name "person's name"] ['level class-level] ['courses list-of-courses])
creates a new student, with initial status as specified in the optional arguments, and returns the student object. For example,
(make-student 'name "Alice" 'level 'sophomore) would return a sophomore-level student named "Alice", not registered for any courses (because the "courses" argument was omitted). Note that if the "courses" argument is provided, it must be a list of course objects (see below).
(make-course ['name "course name"] ['prof professor] ['credits number of credits])
creates a new course, with initial status as specified in the optional arguments, and returns the object. Note that if the "prof" argument is provided, it must be a person object (see above). If the "credits" argument is provided, it should be a whole number.
(describe person)
prints the person's name.
(describe student)
prints the student's name, academic level, and the number of courses the student is registered for.
(describe course)
prints the course name and number of credits, and describes the professor.
(professor-of course)
returns the person object who is the professor of the course.
(courses-of student)
returns a list of the course objects for which the student is currently registered.
(name-of person)
returns the person's name.
(name-of course)
returns the course title.
(add-course student course)
adds the specified course to the list of courses the student is taking, and returns the new list of courses.
(drop-course student course)
removes the specified course from the list of courses the student is taking, and returns the new list of courses. If the student is not registered for the specified course, it does nothing and simply returns the current list of courses.

Last modified: Fri Feb 16 13:32:24 EST 1996
Stephen Bloch / sbloch@boethius.adelphi.edu