Object-Oriented Programming 1: 6.2 Restaurant Assignment

  1. Make FoodItem abstract.
    1. Set the Prepare method to abstract.
    2. Check your work: Build the solution.
    3. Note: The Meal and Drink method can no longer call the abstract FoodItem's Prepare method.

    4. Remove the call to base in the Meal class Drink class prepare methods.
    5. Check your work: Build the solution.
    6. Note: The FoodItem class needs to be abstract in order to contain the abstract Prepare method.

    7. Set the FoodItem class to abstract.
    8. Check your work: Build the solution.
    9. Note: The Drink class does not have a Prepare method.

    10. Define a Prepare method in the Drink class. Set it to override FoodItem's Prepare method.
    11. Check your work: Build the solution and ensure that the code compiles without errors or warnings.
    12. Set Drink class to abstract.
    13. Set ColdDrink class to abstract.
    14. Check your work: Build the solution and ensure that the code compiles without errors or warnings.
  2. Pour the Drink.
    1. Define a Pour method in the Drink class.
    2. Have the overriding Prepare method call Pour.
    3. Check your work: Build the solution and ensure that the code compiles without errors or warnings.
  3. Set Remaining Abstract Methods.
    1. Set the Meal, CookedMeal, UncookedMeal, and HotDrink methods abstract.
    2. Check your work: Build the solution and ensure that the code compiles without errors or warnings.
  4. Protect the Cook method.
    1. Within the Cook's MakeMeal method, instantiate a new Meatloaf.
    2. Place a call to the Meatloaf's Cook method.
    3. Check your work: Build the solution.
    4. Note: The cook is currently able to call the meatloaf's Cook method. He should not be able to call the method directly. He only needs to call the Prepare method.

    5. Define the Cook method as protected within CookedMeal class.
    6. Check your work: Build the solution.
    7. Note: If the virtual Cook method in CookedMeal is protected, then all descendents which override it must also be protected.

    8. Define the Cook method as protected within the Meatloaf and PotRoast classes.
    9. Check your work: Build the solution.
    10. Note: The cook cannot call the meatloaf's Cook method directly because it is no longer public.

    11. Remove the test code from the Cook class.
    12. Check your work:
  5. Customize the Cook method in descendents of the CookedMeal class.
    1. Set the CookedMeal.Cook method to abstract.
    2. Check your work: Build the solution.
    3. Note: The Meatloaf and PotRoast class can no longer call to base in their cook methods, due to Cook class being abstract.

    4. Remove the call to base.Cook within the Meatloaf and PotRoast Cook methods.
    5. Check your work:
  6. Custom ToString method for FoodItems.
    1. Have ToString display the result of FoodItem.Type
    2. Check your work:
      1. Run the application
  7. Refactor FoodItem.Type to include spaces
    1. Set the Type property to virtual.
    2. Define a Type property in TurkeyClub and PotRoast. Set it to override.
    3. Have the Type property return an string rather than the result of this.GetType().Name
    4. Check your work:
      1. Run the application
  8. Give Food Calories
    1. Define an abstract Calories property in the FoodItem class.
    2. Check your work: Build the solution and ensure that the code compiles without errors or warnings.
    3. Define overriding Calories properties in all instantiated food classes.
    4. Check your work:
      1. Run the application
  9. Display FoodItem Calories
    1. Update FoodItem's ToString to include calories in this format: FoodItemName (Calories).
    2. Check your work:
      1. Run the application
  10. Submit