The Housing Office at a local college maintains a database of student dorm rooms. In this assignment, you will develop data definitions and functions for dorm rooms.
Remember that all functions should have a contract and a purpose, and should
be tested using check-expect
.
Develop a data definition for a date. Remember that a data definition consists of the define-struct needed to model the definition, and the accompanying documentation. Provide three examples of dates. (Hint: think carefully about how you want to represent a date. Choose a representation that will make it easy to compare two dates, as in Problem 4, below).
earlier?
that consumes two dates, and
returns true if the first date occurs earlier than the second date. The
function returns false otherwise.
hired-before-date?
that consumes an RA and a
date. The function returns true if the RA was hired before the given date,
and returns false otherwise.
allocate-room
which consumes a room and produces a
room. The produced room is the same as the original, except that the
allocate-if-safe
that
consumes a room and produces a room. If adding an additional student to the
room would exceed the maximum capacity of the room, the room is returned
unchanged. Otherwise, the room that is returned is the same as the original,
except that the
room-charge
that consumes a room. The function calculates the
semester housing charge
assessed to a student.
The housing charge is calculated by adding 20% to the cost of maintaining the
room,
adding a surcharge of $300 if the room is part of a suite, and dividing
by the number of current occupants in the room.
match?
that consumes a room, the kind of
building a student wants to reside in, and a string that indicates whether the
student wants to live in a "single", "double", or "triple".
The room matches the student's criteria if the kind of building the student
wants is the same as the kind of building the dorm room is in, and if the
maximum capacity of the dorm room is the same as the capacity requested by
the student (for a single, the maximum capacity should be 1, for a double, 2, and for a triple, 3).
The function
returns true if the given room matches the student's request, and returns
false otherwise.
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. Both partners' names and login names must appear in a comment at the top of the file.