University of Texas at El Paso
Banner
Compuer Science
   
Text/HTML Minimize    

CS 2401 Assignment #3

Date Assigned: Tuesday, February 12, 2008.

Due Date: Wednesday, February 20, 2008.

Goals: to gain further familiarity with inheritance and polymorphism.

Assignment: In this assignment, you will extend a program that was lab assignment 10 in CS 1401 in Fall 07. In this assignment, students wrote a program to help waiters by letting them enter the names of different menu items and other information and then print a detailed receipt. You can have more details about this assignment at web address http://www.cs.utep.edu/vladik/cs1401.07a/assign10.html. You will start with the solution of the assignment at web address http://www.cs.utep.edu/vladik/cs1401.07a/assign10sol.html.

For this assignment, you will have to implement three subclasses of FoodItem. One subclass is for main dishes. The customer selecting a main dish will have to choose between a soup or salad. Also, there is a choice of side dish. Another subclass is for drinks. The customer must select small, medium or large. The third class is for other dishes. This class has a boolean field indicating if the item is an apetizer.

Modify the given program as follows. When the program asks the waiter for items, it asks if it's a main dish, drink or other. Then the further questions will depend on which type of food item is entered. Store all the elements in the same array. This uses polymorphism since not all objects are of the same class. Then, the program prints the detailed receipt, but it prints it by categories. First apetizers, then main dishes, then others that are not apetizers, then drinks. For each type of food, it includes the information pertaining to the item, for example if it's a drink, it prints small, medium or large. This is done by going through the array and checking what type of object is stored with the instanceof operator.

Deliverables: as announced in the labs.