CS 1101 - C-term 10

Homework 10 - Modelling a Discussion Board

Due: Friday, February 26 at 5pm

Note that you are being given a week to complete this assignment. Don't wait until the last minute to get started - it's a long assignment.


Assignment Goals

To make sure you can create linked data structures and write programs using assignment.

Remember to follow the Expectations on Homework when preparing your solutions.


The Assignment

Developing a Discussion Board, Part 1

Across homeworks 10 and 11 you will develop a simple version of a discussion board. In a discussion board like you've been using on myWPI, each class has a collection of forums and each forum has a bunch of posted messages. When you log into myWPI, messages are marked according to whether you (personally) have read them or not. (To keep this assignment simpler, we will ignore the grouping--called threading--of messages with the same topic). In addition, certain operations (creating new forums) are restricted to users of a certain kind (faculty versus students). Finally, access to course areas is updated automatically from the registrar's information about who is in each course.

This description suggests that a discussion board system relies on two major pieces of information: information on registered users of the system and discussion board contents for each course. More specifically:

See the note about testing in question 8. You do not need to provide test cases for individual functions. Also, you do not need to show test cases that will produce errors.

  1. Write the data definitions for lists of registered users and discussion board contents (list of courses) as described above.

  2. Define two variables, one for the list of registered users and one for the list of courses. Give the registered users list an initial value of at least 4 users, none of whom are participating in any course. Initialize the discussion board contents with no courses.

  3. Write a function add-user that consumes a user's real name and username and produces void. Its effect is to add a new user to the list of registered users. The new user should not contain any courses. You may assume that the given username is not already in the list of registered users. The new user may go anywhere in the list.

  4. Write a function find-user that consumes a list of users and a string and returns the user with the given username. The function returns an error if the named user is not in the list. This may be a useful helper function for later problems.

  5. Write a function add-course that consumes a course title and professor's username and produces either void or raises an error. If the professor is not a registered user, the function raises an error and leaves the discussion board contents unchanged. If the professor is in the list of registered users, the function creates a new course in the discussion board (the new course has no forums and will list the professor as a faculty member.) The title of the new course should be listed in the courses that the professor participates in (inside the professor's registered-user structure).

  6. Write a function find-course that consumes a course title and produces a course. The produced course should be the one from the discussion board with the given title. The function produces an error if the named course doesn't exist in the discussion board. This may be a useful helper function for later problems.

  7. Write a function add-to-course that consumes a username, a course title and the user's role in the course and produces void. The effect of the function is to add the course title to the list of courses in which the user is participating and to add the given username as a member in the named course (with the given role).
  8. Produce a sequence of test cases for the interactions between these functions. You don't need to use (check-expect...), just put the function calls in a comment box in the definitions window. You will not be graded on tests for the individual functions (but we strongly suggest that you test the individual functions as you write them anyway).

What to Turn In

Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Follow the naming conventions when naming your file. Please make sure both partners' names and wpi login names are listed in a comment at the top of the file.