CS U212 - Lab 3
The lab assignment is to be completed in pairs. Each pair works at one computer. Remember to trade roles!
Part I: Structure Definitions
For each of the following word problems, extract
structure definitions for the data involved.
Exercise 1:
A restaurant reservation system keeps track of tables in the
restaurant. For each table, the system knows how many seats there
are and whether or not it is currently reserved.
Exercise 2:
Each dish served by the restaurant must be served within a particular
temperature range. A dish has a name, a price, a minimum serving temperature,
and a maximum serving temperature (in degrees Fahrenheit).
Switch Roles
Exercise 3:
A food order consists of an appetizer, an entree, and a dessert.
Each course is a dish as described in Exercise 2.
Exercise 4:
The restaurant is divided into a bar area, three sections of tables,
and the entry area. The bar is staffed by one bartender, and the
entry area is staffed by the maitre d'. Each section is tended by
two servers.
Part II: Data Definitions
Take your first three structure definitions from above and turn them into data definitions. Recall that a data definition for structured data specifies what kind of data each structure field contains. Refer to Section 6.4 of HtDP if you need to review!
Part III: Templates
Construct a template for each of the data definitions from Part II. Recall that the template describes what we know about the input to a function. For each expression in your template, record the kind of data to which it evaluates. If you need to review templates for compound data, look in Section 6.5 of HtDP.
Part IV: From Templates to Functions
Consider the template you built from the data definition from Exercise 2. Design the following functions based on this one template. You must formulate examples and tests!
-
Using your solution to Exercise 1 above (data definition, structure
definition and template), develop a program that consumes a table
and reserves it for the night
-
Using your solution to Exercise 2 above (data definition, structure
definition and template), develop a program that consumes a dish
and its temperature and determines if the dish can be served.
-
Our software should generate the restaurant menus automatically.
Develop a program that consumes a dish and produces an image containing
that dish's name and price as it would appear in the menu.
-
Our Boston restaurant is a huge success, and so we will open a new
location in Paris. The chefs there do not understand the Fahrenheit
temperature ranges within which our dishes must be served. Develop a
program that consumes a dish and produces a dish just like the given
one, but where the temperature range is given in Celcius.
-
Our Parisian customers cannot pay in US dollars. Develop a program
that consumes a dish and produces one whose price is given in Euros.
Use Google to find the conversion rate.
-
Using your solution to Exercise 3 above (data definition, structure
definition and template), develop a program that determines the
total cost of a given order, including a 21% gratuity.
-
Using your solution to Exercise 4 above (data definition, structure
definition and template), develop a program that consumes a
restaurant and an employee's name, and determines the name of the
area in which the given employee is working.
Part V: Challenge Problem
Done already? Then try to solve this problem:
Our restaurant needs you to design a visual reservation management
system. The main (only) room has five tables of different sizes and
shapes. At any given time each table has a possible associated
reservation, position, etc.
- Create a full data definition for the restaurant world that
includes the current time (minutes and hours is fine).
- Write a function that increments the minutes of the current time;
remember to wrap minutes into hours, and loop 24 to 0.
- Write a function to display the floor layout of the
restaurant. Tables should display differently (color or outline/solid)
when they are reserved and after the reservation time has passed.
- Write a function that cleans up old reservations when more than
one hour has passed. Attach this function to the time increment.
- Put all this together with a big-bang and watch your restaurant
reservations change with time.