C#

For this project you will be building sandwich objects and allowing users to order.

Sandwich Class

Properties for this class
Meat
Sandwich Number
Price
Calories
Notes (This is for toppings requested)
You must have a constructor
Main Program

Offer a Company Header Line
You will need an array or list of Sandwich Objects
Populate this array with 10 sandwiches
must use the constructor
Menu
Employee
Must prompt user for username and password
After 3 attempts they get kicked out of the program
Customer Menu
Employee
User can edit sandwich properties
Give menu where the employee can modify a sandwich
Allow user to modify any aspect of the sandwich properties.
Customer
Must loop until the user is finished entering sandwich orders
Must save the orders to an array or list for future use in totaling
Once order is complete:
Calculate the 5.5% sales tax
Show out the entire order
Show out the subtotal
Show out the tax amount
Show out the grand total

Respuesta :

Answer:

Check the explanation

Explanation:

class AssemblyLine

{

// Builder uses a complex series of steps

//

public void Assemble(SandwichBuilder sandwichBuilder)

{

sandwichBuilder.AddMeats();

sandwichBuilder.AddSandwich Number();

sandwichBuilder.AddPrice();

sandwichBuilder.AddCalories();

}

}

class Sandwich

{

private string _sandwichType;

private Dictionary<string, string> _ingredients = new Dictionary<string, string>();

// Constructor

public Sandwich(string sandwichType)

{

this._sandwichType = sandwichType;

}

// Indexer

public string this[string key]

{

get { return _ingredients[key]; }

set { _ingredients[key] = value; }

}

public void Show()

{

Console.WriteLine("\n---------------------------");

Console.WriteLine("Sandwich: {0}", _sandwichType);

Console.WriteLine(" Meat: {0}", _ingredients["meat"]);

Console.WriteLine("Sandwich Number: {0}", _ingredients["sandwich Number"]);

Console.WriteLine(" Price: {0}", _ingredients["price"]);

Console.WriteLine(" Calories: {0}", _ingredients["calories"]);

}

}

abstract class SandwichBuilder

{

protected Sandwich sandwich;

// Gets sandwich instance

public Sandwich Sandwich

{

get { return sandwich; }

}

// Abstract build methods

public abstract void AddMeats();

public abstract void AddSandwich Number();

public abstract void AddPrice();

public abstract void AddCalories();

}

class TurkeyClub : SandwichBuilder

{

public TurkeyClub()

{

sandwich = new Sandwich("Turkey Club");

}

public override void AddMeats()

{

sandwich["meat"] = "Turkey";

}

public override void AddSandwich Number()

{

sandwich["sandwich Number"] = "10";

}

public override void AddPrice()

{

sandwich["price"] = "50";

}

public override void AddCalories()

{

sandwich["calories"] = "361";

}

}

/// <summary>

/// A ConcreteBuilder class

/// </summary>

class BLT : SandwichBuilder

{

public BLT()

{

sandwich = new Sandwich("BLT");

}

public override void AddMeats()

{

sandwich["meat"] = "Bacon";

}

public override void AddSandwich Number()

{

sandwich["sandwich Number"] = "2";

}

public override void AddPrice()

{

sandwich["price"] = "None";

}

public override void AddCalories()

{

sandwich["calories"] = "none";

}

}

/// <summary>

/// A ConcreteBuilder class

/// </summary>

class HamAndCheese : SandwichBuilder

{

public Ham()

{

sandwich = new Sandwich("Ham ");

}

public override void AddSandwhich Number()

{

sandwich["sandwhich number"] = "1";

}

public override void AddMeats()

{

sandwich["meat"] = "Ham";

}

public override void AddPrice()

{

sandwich["price"] = "None";

}

public override void AddCalories()

{

sandwich["calories"] = "none";

}

}

static void Main(string[] args)

{

SandwichBuilder builder;

// Create shop with sandwich assembly line

AssemblyLine shop = new AssemblyLine();

// Construct and display sandwiches

builder = new Ham();

shop.Assemble(builder);

builder.Sandwich.Show();

builder = new BLT();

shop.Assemble(builder);

builder.Sandwich.Show();

builder = new TurkeyClub();

shop.Assemble(builder);

builder.Sandwich.Show();

// Wait for user

Console.ReadKey();

}