CS 1101 - Aterm 15

Homework 2 - Defining Structs

Due: Thursday, September 10 at 5pm

Read the expectations on homework. You should work with your homework partner on this and all remaining homework assignments.

Assignment Goals


The Assignment

In this assignment, you will develop data definitions and functions for restaurants, and for reservations made at restaurants.

Remember that each function should have a signature and a purpose, and should be tested using check-expect.

Problems

  1. A restaurant is specified as follows: the name of the restaurant, the type of food served (Italian, seafood, steakhouse, etc.), the number of tables in the restaurant, the total capacity (i.e. the number of seats), and whether or not the restaurant provides vegetarian offerings. Develop a complete data definition for a restaurant. Provide three examples of restaurants created using your data definition.

  2. In a comment in the Definitions window, write the function names and signatures for all the functions (constructor, selector(s), predicate) that Racket creates from your define-struct in the previous question.

  3. Write a function restaurant-type that consumes a restaurant and produces a string. If the restaurant has at least 30 tables and the capacity to hold at least 250 customers, the function produces "event venue". Assuming that's not the case, then if the restaurant provides vegetarian offerings, the function produces "vegetarian-friendly". Otherwise, the function produces the type of food served at the restaurant.
  4. Develop a data definition for a restaurant reservation. A reservation contains the restaurant the reservation is for, the name of the person making the reservation, his/her telephone number, the date that the reservation is for, and the number of people in the party. Carefully consider how you want to represent the date of the reservation (see Problem 6 below). Provide three examples of restaurant reservations using your data definition.

  5. Write a function add-to-party that consumes a restaurant reservation and a number and creates a restaurant reservation. The reservation that is produced is the same as the original, except that the number of people in the party has been increased by the given number.

  6. Write a function precedes? that consumes two dates, and returns true if the first date precedes the second date. Otherwise the function returns false.

  7. Write a function reservation-OK? that consumes a room reservation and and a date (ostensibly today's date) and produces a boolean. A reservation is not OK if it is for a date that precedes the given date, or if it is for a party with more people than the restaurant can hold. Otherwise, the reservation is OK.

Grading

Here is the grading rubric that the graders will use for Homework 2. Programs must run to receive credit. Note that code that is commented out will not be graded.

What to Turn In

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 in CS 1101.Both partners' names and wpi usernames must appear in a comment at the top of the file.