CS 1101 - Aterm 08

Homework 2 - Defining Structs

Due: Tuesday, September 9 at 11:59pm

Read the expectations on homework.

Assignment Goals


The Assignment

The facilities department at a local college keeps track of information about the various rooms in academic buildings on campus, and the room reservations that are made for courses. In this assignment, you will develop data definitions and functions for rooms and room reservations.

Remember that all functions should have a contract and a purpose, and should be tested using check-expect.

Problems

  1. A room is specified as follows: the building, the room number, the number of seats, the number of computer stations, whether or not the room is equipped as an electronic classroom (with hardware and software at the instructor's podium), and whether or not the desks and chairs are movable. Develop a data definition for a room. Include the define-struct needed to model your room and three examples of rooms created with your definition.

  2. State all of the operators (with their contracts) that are created from your define-struct in the previous question.

  3. Write a function seats-available that consumes a room and the number of students currently registered for seats in the room and produces a number. The function returns the number of available seats in the room.

  4. Write a function room-type that consumes a room and produces a string. If the room is both equipped as an electronic classroom, and has at least one computer station for every two seats in the classroom, the function produces "computer lab". If it's not a computer lab, and if the room has at least 100 seats and is an electronic classroom, the function produces "lecture hall". Otherwise, the function produces "general purpose".
  5. Develop a data definition for a room reservation. A reservation contains the professor's last name, the professor's department, the date that the reservation was made, and the room being reserved. Include the define-struct needed to model your reservations and three examples of reservations created with your model. Carefully consider how you want to represent the date of the reservation (see Problem 8 below).

  6. Write a function reservation-OK? that consumes a reservation and produces a boolean. A reservation is not OK if it is for a CS course and the room contains no computer stations, or if it is for a HU course and the furniture is not movable. Otherwise, the reservation is OK.

  7. Write a function change-instructor that consumes a room reservation and the name of a professor and creates a room reservation. The reservation that is produced is the same as the original, except that the name of the professor reserving the room has been changed to the given name.

  8. Write a function reserved-before-deadline? that consumes a reservation and a date that represents the deadline for reservations. The function returns true if the given reservation was made before the deadline.

What to Turn In

Using web-based turnin, turn in a single file hw2.scm containing all code and documentation for this assignment. Both partners' names must appear in a comment at the top of the file.