CIT137Project 4Due: 3-8-2012

Complete the following requirements that will demonstrate your understanding of

  • Inheritance (Superclasses / Subclasses)
  • Abstract classes
  • Overriding and overloading methods
  • Polymorphism

NOTE: All your class names should start with your initials.

Requirements

Design a set of classes for dining out which will demonstrate inheritance & polymorphism.

An abstractFMLRestaurant class should minimally have the following instance variables and abstract methods.

Name of Restaurant (String)

Bill Amount (double)

NOTE: Recall that abstract methods in the superclass do NOT provide any implementation code.

  • displayMenu()Displays an appropriate menu for a given restaurant

Minimally, include at least two foods and two drinks with prices.

The menu for the Fast Food Restaurant should display in the Console Window.

  • computeBill()Compute the bill and display to user.

The bill for the Fancy Restaurant should automatically include a tip of 15%.

  • orderFood()Allow a customer to order food.

You can assume that only one customer is ordering food.

  • payBill()Allow customer to possibly specify a tip (for the Coffee Shop) or bigger tip for Fancy Restaurant and to approve the payment. The Fast Food Restaurant is cash-only while the other two accept Credit Cards as well.

Code a public static method named greeting() that is called for all restaurants. It displays a standard greeting to all customers of any restaurant such as “Hello, I will take your order when you are ready?

In the FMLRestaurant superclass, code an eatOut() method that will invoke the methods in the order they would occur in a typical restaurant scenario.

Implement FMLFastFood, FMLCoffeeShop, and FMLFancy subclasses of FMLRestaurant that implement or use the methods above.

To demonstrate the polymorphism, declare several restaurant objects in a class named FMLProject4, which refer to the various subclasses. Store these restaurant objects in an array of type FMLRestaurant. Calling the eatOut() method for each restaurant will show that each behaves in its own way, appropriate to that type of restaurant. A subclass may override the eatOut() method, if the order of method calls defined in the eatOut()method in the FMLRestaurant class is not appropriate for that subclass. One example, would be the payBill() method because tips are included for a FMLFancy restaurant, and maybe FMLCoffeeShop, but not for FMLFastFood.

NOTE: Do not get bogged down with the details of all the functionality for these classes. Perform simple operations that meet the requirements and focus on the polymorphic effects.

JRNorth1Spring 2012