Milestone 3 Requirements

Web Only

This textbook was authored for the CIS 400 - Object-Oriented Design, Implementation, and Testing course at Kansas State University. This section describes assignments specific to the Fall 2022 offering of that course. Prior semester offerings can be found here. If you are not enrolled in the course, please disregard this section.

For this milestone, you will be creating base classes for entrées, sides, and drinks served at Dino Diner. This will involve refactoring some already written classes, as well as adding some new ones.

General requirements:

  • You need to follow the style laid out in the C# Coding Conventions

  • You need to document your code using XML-style comments, with a minimum of <summary> tags, plus <param>, <returns>, and <exception> as appropriate.

Assignment requirements:

You will need to:

  • Create bases class for Burgers, Drink and Sides
  • Create new enum for:
    • SodaFlavors
  • Create new classes for:
    • T-Rex Triple Burger
    • Carnotaurus Cheeseburger
    • Deinonychus Double
    • Allosaurus All-American Burger
    • Plilosoda
    • Cretaceous Coffee
  • Refactor existing classes to use inheritance

Purpose:

This milestone serves to introduce and utilize aspects of polymorphism including base classes, abstract base classes, abstract methods, virtual methods, and method overriding. While the actual programming involved is straightforward, the concepts can be challenging to master. If you have any confusion after you have read the entire assignment please do not hesitate to reach out to a Professor Bean, the TAs, or your classmates over Discord.

Abstract Base Classes

You will need to create a base class for each of the kinds of items served at Dino Diner: Entrees, Sides, and Drinks. Because you will never instantiate one of these classes directly i.e. you would never write:

Side side = new Side();

But rather:

Side side = new Triceritots();

You will want to declare these base classes abstract.

As you create these base classes, carefully consider what properties all items in that category have in common. These properties should then be implemented in the base class, which will be one of the following:

  • A regular property if the exact same functionality will be used in the derived classes and should never need to change,
  • A virtual property if the exact same functionality will be used in almost all derived classes, but at least one is a special case, or
  • An abstract property if the derived classes all have the same property but the returned values are different for each one.

Each abstract base class should be placed in the corresponding file and namespace, i.e. the class Side should be declared in the DinoDiner.Data.Sides namespace and in a file named Side.cs. The classes you need to implement are Entree, Side, and Drink.

To give you a head start, your Entree base class should look like:

namespace DinoDiner.Data.Entrees
{
    /// <summary>
    /// A base class for all entrees sold at DinoDiner
    /// </summary>
    public abstract class Entree
    {
        /// <summary>
        /// The name of the Entree
        /// </summary>
        public abstract string Name { get; }
        
        /// <summary>
        /// The price of the Entree
        /// </summary>
        public abstract decimal Price { get; }

        /// <summary>
        /// The calories of the Entree
        /// </summary>
        public abstract uint Calories { get; }
    }
}

Create a Burger Base Class

Dino Diner offers a completely customizable burger, with several ‘standard’ configurations. To support this approach, you will want to create a base Burger class that contains all the possible Burger ingredients available at Dino Diner. This base class should be named Burger and should inherit from the Entree class. The other burger classes (TRexTriple, CarnotaurusCheeseburger, DeinonychusDouble, and AllosaurusAllAmericanBurger) and set the appropriate default values for the boolean and enumeration properties through a parameterless constructor.

The burger should provide a Patties property of type Uint indicating the number of patties it is served with. A single pattie is 204 calories, and adds $1.50 to the price of the burger.

The other burger ingredients should be represented with bool properties and are have the following properties:

Ingredient Calories Price
Ketchup 19 $0.20
Mustard 3 $0.20
Pickle 7 $0.20
Mayo 94 $0.20
BBQ 29 $0.10
Onion 44 $0.40
Tomato 22 $0.40
Lettuce 5 $0.30
AmericanCheese 104 $0.25
SwissCheese 106 $0.25
Bacon 43 $0.50
Mushrooms 4 $0.40

Create new Enum

You will need to create a new enum in the DinoDiner.Data.Enums namespace to represent the soda flavors offered at Dino Diner which should be named Soda Flavor and contain:

  • Cola
  • CherryCola
  • DoctorDino
  • LemonLime
  • DinoDew

Create new Classes

You will need to create three new classes, TRexTriple, CarnotaurusCheeseburger, DeinonychusDouble, AllosaurusAllAmericanBurger, Plilosoda, and Cretaceous Coffee.

T-Rex Triple

The class TRexTriple should be declared in the DinoDiner.Data.Entrees namespace. It should inherit from the Burger base class. The default configuration is three patties served with Ketchup, Mayo, Pickle, Onion, Lettuce, and Tomato. The name should always be “T-Rex Triple”.

Carnotaurus Cheeseburger

The class CarnotaurusCheeseburger should be declared in the DinoDiner.Data.Entrees namespace. It should inherit from the Burger base class. The default configuration is one patties served with Tomato, Ketchup, Pickle, and AmericanCheese. The name should always be “Carnotaurus Cheeseburger”.

Deinonychus Double

The class DeinonychusDouble should be declared in the DinoDiner.Data.Entrees namespace. It should inherit from the Burger base class. The default configuration is two patties served with BBQ, Pickle, Onion, Mushroom, and SwissCheese. The name should always be “Deinonychus Double”.

Allosaurus All-American Burger

The class AllosaurusAll-AmericanBurger should be declared in the DinoDiner.Data.Entrees namespace. It should inherit from the Burger base class. The default configuration is one patty served with Ketchup, Mustard, and Pickle. The name should always be “Allosaurus All-American Burger”.

Plilosoda

The class Plilosoda should be declared in the DinoDiner.Data.Drinks namespace. It represents a soda. It should have a Flavor property of type SodaFlavor with getters and setters. It should have a Size property of type ServingSize with getters and setters.

It should have a Price get-only property of type decimal, a Calories get-only property of type uint, and a Name get-only property using the values laid out in the table below. Note the use of spaces in the names!

Flavor Size Price Calories Name
Cola Small $1.00 180 Small Cola Plilosoda
CherryCola Small $1.00 100 Small Cherry Cola Plilosoda
Doctor Dino Small $1.00 120 Small Doctor Dino Plilosoda
Lemon-Lime Small $1.00 41 Small Lemon-Lime Plilosoda
DinoDew Small $1.00 141 Small Dino Dew Plilosoda
Cola Medium $1.75 288 Medium Cola Plilosoda
CherryCola Medium $1.75 160 Medium Cherry Cola Plilosoda
Doctor Dino Medium $1.75 192 Medium Doctor Dino Plilosoda
Lemon-Lime Medium $1.75 66 Medium Lemon-Lime Plilosoda
DinoDew Medium $1.75 256 Medium Dino Dew Plilosoda
Cola Large $2.50 432 Large Cola Plilosoda
CherryCola Large $2.50 240 Large Cherry Cola Plilosoda
Doctor Dino Large $2.50 288 Large Doctor Dino Plilosoda
LemonLime Large $2.50 98 Large Lemon-Lime Plilosoda
DinoDew Large $2.50 338 Large Dino Dew Plilosoda

Cretaceous Coffee

The class CretaceousCoffee should also be declared in the DinoDiner.Data.Drinks namespace. It should have a Size property of ServingSize. It should have a Name property of type string that returns “[Size] Cretaceous Coffee” where [Size] is the size of the coffee. It should have a Price property of type Decimal that returns $0.75 for small, $1.25 for medium, and $2.00 for large. It should also have a Calories property of type uint that returns 0 calories. It should also have a boolean property Cream indicating the coffee is served with cream that defaults to false. If it is true, the Calories property should instead return 64.

Refactor Existing Classes to use Inheritance

Once you have the Side base class, refactor your existing side classes (Fryceritops, MeteorMacAndCheese, MezzorellaSticks, and Triceritots) to inherit from it. You will also want to refactor their existing properties as they should now inherit many of them from the base class; some may be deleted, others will need to be refactored as overridden methods by adding the override keyword.

Likewise you will want to refactor the existing entree base classes (Brontowurst, DinoNuggets, PterodactylWings, and VelociWrap) to inherit from the Entree base class. You will want to refactor their properties as well.

Submitting the Assignment

Once your project is complete, merge your feature branch back into the main branch and create a release tagged v0.3.0 with name "Milestone 3". Copy the URL for the release page and submit it to the Canvas assignment.

Grading Rubric

The grading rubric for this assignment will be:

25% Structure Did you implement the structure as laid out in the specification? Are the correct names used for classes, enums, properties, methods, events, etc? Do classes inherit from expected base classes?

25% Documentation Does every class, method, property, and field use the correct XML-style documentation? Does every XML comment tag contain explanatory text?

25% Design Are you appropriately using C# to create reasonably efficient, secure, and usable software? Does your code contain bugs that will cause issues at runtime?

25% Functionality Does the program do what the assignment asks? Do properties return the expected values? Do methods perform the expected actions?

Warning

Projects that do not compile will receive an automatic grade of 0.