CS 1101 (A05) Homework 7: Discussion Boards Continued

Due: October 11 (Tuesday) at 11:59pm

Assignment Goals


You must be in Advanced Student Language Level for this homework. Go to Choose Language under the Language menu to change your language level.


Developing a Discussion Board, Part 2

Copy your data definitions and solutions to question 2 from homework 6 to your file for homework 7. This assignment adds functions to the discussion board system from homework 6.

If you see helpers that can be used across multiple problems, define (and use) them.

As in homework 6, we will grade your tests cases as a whole sequence (question 6). We will not grade test cases for individual functions.

  1. Write a function find-course that consumes a course title and produces a course (structure). The produced course should be the one from the discussion board contents with the given title. Use this function as a helper in the remaining problems.

  2. Write a function add-forum that consumes a course title, a username, and a forum title and produces void. The effect of this function is to add a new forum to the course with the given title if the given username is a faculty member for the course. If the given username is a student or not a member of the course, then the forum stays unchanged. You may assume that the forum title has not been used on another forum in the same course.

  3. Write a function post-message that consumes a course title, a forum title, a username, message title, and message contents and produces void or "unknown forum". The effect of this function is to add a new message with the given input data to the discussion board, marked as read only by the person who posted the message. The function should produce "unknown forum" if the forum is not in the named course.

  4. Write a accumulator-style function get-unread-messages that consumes a username, a course title and a forum title and produces a list of the messages in the named forum that the user with the given username has not yet read. How does the order of the output compare to that of the input? (answer in a comment)

  5. Write a function mark-all-read that consumes a username, a course title, and a forum title and produces void. The effect of the function is to mark the given username as having read all messages that he had not read previously. You may use Scheme's built-in function member : any-value list[] -> false OR list[]. member returns the sublist whose first element is the sought value or false if the value is not in the list.

    > (member 2 (list 0 1 2 3))
    (list 2 3)
    > (member 20 (list 0 1 2 3))
    false
    

  6. Show the sequence of test cases that you would use to test the interactions between these functions.


What to Turn In

Turn in a single file hwk7.ss (or hwk7.scm) containing all code and documentation for this assignment. Make sure that all students' names are in a comment at the top of the file.


Guidelines


Back to the Assignments page