You do not have to show test cases that result in error conditions.
You do not have to show test cases for any function that involves mutation. The graders will be running your programs with their own set of tests (see below). However, make sure you understand how to construct tests for functions that use mutation (you might be asked something about this on the third exam).
Courses
can contain a list of courses.
Students
can contain a list of students. Both variables should initially be empty.
add-student
that consumes the name and ID of a student
and produces void. The function checks to make sure that a student with the given
ID doesn't already exist in Students
. If such a student already exists, the
function produces an error "student already exists". If there is no such student, the
function adds the student to Students
. The added student's list of courses is
initially empty.
add-course
that consumes a department, course number,
the name of a faculty member, and the maximum enrollment, and produces void. The function checks
to make sure that a course with the given department and course number doesn't already
exist in Courses
. If such a course already exists, the function produces an
error "course already exists". If there is no such course, the function adds the course
to Courses
. The list of students in the course is initially empty.
add-to-course
that consumes a student's ID, a department,
and a course number and produces void.
If the student or the
course doesn't exist, the function produces an appropriate error.
If there is still room in the course, the function
adds the student with the given ID to
the course with the given department/course number, and adds the course with the
given department/course number to the student's list of courses. If the maximum enrollment for
the course has already been reached, the function produces an appropriate error.
largest-enrollment
that doesn't consume anything.
The function produces the course
in Courses
with the largest current enrollment (you should be returning the
course that has the most students in its list of students, not necessarily the course that has
the largest maximum enrollment). If there are no courses
in Courses
,
the function produces an appropriate error. You must use accumulator-style programming to
solve this problem.
(add-student "Joe" 123) (add-student "Ann" 456) (add-student "Chris" 789) (add-course "CS" 1101 "Hamel" 100) (add-course "BI" 1000 "Rulfs" 20) (add-course "MA" 2201 "Servatius" 50) (add-to-course 456 "MA" 2201) (add-to-course 456 "CS" 1101) (add-to-course 123 "CS" 1101) (add-to-course 789 "BI" 1000) (largest-enrollment)Make sure that your functions adhere to the signature/purpose given, otherwise the test cases won't run. Also, make sure you name the functions as indicated in each problem.
Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Name your file according to the naming conventions for files. Make sure both partners' names and wpi login names appear in a comment at the top of the file.