1 Lab Objectives
2 Have Classes, Will Travel
3 What to Turn In

Lab 3–Standard, Design practice: class hierarchies

1 Lab Objectives

  1. Practice going from a problem description to class hierarchies

  2. Practice where to put the parts of a method across classes

2 Have Classes, Will Travel

A new travel website plans to manage customers’ reservations for special deals on flights and hotel stays. Flights have a date, departure city and arrival city. Hotel stays have a hotel name, city check-in date, and check-out date. The travel site maintains a collection of its available deals, as well as information on which customers have reserved which deals. To keep things simple, we will assume that there is no limit on the number of reservations available for each flight or hotel deal (overbooking, galore!).

To increase revenue, the site wants to monitor customers’ reservations, and offer them hotel deals for their destination city and date of arrival (ignore return dates, length of stay, etc). The site will need a method suggestHotels on customers that returns a list of hotel deals that match a given flight, unless the customer already has a hotel reservation for the arrival date and city of the flight.

Your goal for this lab is to design the set of classes, interfaces, and method names that each class/interface needs to capture the data described above and provide the suggestHotels method. You do not need to fully implement the classes or the suggestHotels method. Simply sketch out the classes and their fields, interfaces and their required methods, and give the headers and description for any methods that you think you would need in each class. The following snippet shows the level of detail we are after (note there are no constructors or method bodies):

  class Dillo extends AbsAnimal {

    int length;

    boolean isDead;

  

    // returns true if dillo is alive and under length 2

    boolean shouldEat() {...}

  }

The suggestHotels method should be listed in some class that you propose. If you think that method would need to call a helper in another class, list the required helper in its class.

You may work on paper or within a Java editor for this, your choice. The goal is to get practice and to discuss your work with others, since there some design choices here. Get together with other students in the lab to discuss how you each approached the problem about 10 minutes before lab time ends. You should see some different approaches that way.

3 What to Turn In

If you typed in your class outlines, upload them to InstructAssist. If you just worked on paper (also fine), just make sure you signed in to get credit for the lab.