Skip to content

Commit

Permalink
Finished Point of Sale Milestone 2
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfschwartz committed Oct 3, 2020
1 parent 05ab0d7 commit 7bbee24
Show file tree
Hide file tree
Showing 68 changed files with 3,019 additions and 272 deletions.
39 changes: 32 additions & 7 deletions Data/Drinks/AretinoAppleJuice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,39 @@
using BleakwindBuffet.Data.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace BleakwindBuffet.Data.Drinks
{
/// <summary>
/// Class defining a AretinoAppleJuice object
/// </summary>
public class AretinoAppleJuice : Drink, IOrderItem
public class AretinoAppleJuice : Drink, IOrderItem, INotifyPropertyChanged
{
public const double SMALL_ARETINO_APPLE_JUICE_PRICE = 0.62;
public const double MEDIUM_ARETINO_APPLE_JUICE_PRICE = 0.87;
public const double LARGE_ARETINO_APPLE_JUICE_PRICE = 1.01;
public const uint SMALL_ARETINO_APPLE_JUICE_CALORIES = 44;
public const uint MEDIUM_ARETINO_APPLE_JUICE_CALORIES = 88;
public const uint LARGE_ARETINO_APPLE_JUICE_CALORIES = 132;

public event PropertyChangedEventHandler PropertyChanged;

private new Size size = Size.Small;
public override Size Size
{
get { return size; }
set
{
size = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Size"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Price"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Calories"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialInstructions"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ToString"));
}
}

/// <summary>
/// Gets price of the drink
Expand All @@ -29,9 +53,9 @@ public override double Price
{
switch (size)
{
case Size.Small: return 0.62;
case Size.Medium: return 0.87;
case Size.Large: return 1.01;
case Size.Small: return SMALL_ARETINO_APPLE_JUICE_PRICE;
case Size.Medium: return MEDIUM_ARETINO_APPLE_JUICE_PRICE;
case Size.Large: return LARGE_ARETINO_APPLE_JUICE_PRICE;
default: throw new NotImplementedException($"Unknown size {size}");
}
}
Expand All @@ -49,9 +73,9 @@ public override uint Calories
{
switch (size)
{
case Size.Small: return 44;
case Size.Medium: return 88;
case Size.Large: return 132;
case Size.Small: return SMALL_ARETINO_APPLE_JUICE_CALORIES;
case Size.Medium: return MEDIUM_ARETINO_APPLE_JUICE_CALORIES;
case Size.Large: return LARGE_ARETINO_APPLE_JUICE_CALORIES;
default: throw new NotImplementedException($"Unknown size {size}");
}
}
Expand All @@ -69,6 +93,7 @@ public bool Ice
set
{
ice = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Ice"));
if (ice)
{
specialInstructions.Add("Add ice");
Expand Down
42 changes: 35 additions & 7 deletions Data/Drinks/CandlehearthCoffee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,40 @@
using BleakwindBuffet.Data.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace BleakwindBuffet.Data.Drinks
{
/// <summary>
/// Class defining a CandlehearthCoffee object
/// </summary>
public class CandlehearthCoffee : Drink, IOrderItem
public class CandlehearthCoffee : Drink, IOrderItem, INotifyPropertyChanged
{
public const double SMALL_CANDLEHEARTH_COFFEE_PRICE = 0.75;
public const double MEDIUM_CANDLEHEARTH_COFFEE_PRICE = 1.25;
public const double LARGE_CANDLEHEARTH_COFFEE_PRICE = 1.75;
public const uint SMALL_CANDLEHEARTH_COFFEE_CALORIES = 7;
public const uint MEDIUM_CANDLEHEARTH_COFFEE_CALORIES = 10;
public const uint LARGE_CANDLEHEARTH_COFFEE_CALORIES = 20;

public event PropertyChangedEventHandler PropertyChanged;

private new Size size = Size.Small;
public override Size Size
{
get { return size; }
set
{
size = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Size"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Price"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Calories"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialInstructions"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ToString"));
}
}

/// <summary>
/// Gets price of the drink
/// </summary>
Expand All @@ -28,9 +53,9 @@ public override double Price
{
switch (size)
{
case Size.Small: return 0.75;
case Size.Medium: return 1.25;
case Size.Large: return 1.75;
case Size.Small: return SMALL_CANDLEHEARTH_COFFEE_PRICE;
case Size.Medium: return MEDIUM_CANDLEHEARTH_COFFEE_PRICE;
case Size.Large: return LARGE_CANDLEHEARTH_COFFEE_PRICE;
default: throw new NotImplementedException($"Unknown size {Size}");
}
}
Expand All @@ -48,9 +73,9 @@ public override uint Calories
{
switch (size)
{
case Size.Small: return 7;
case Size.Medium: return 10;
case Size.Large: return 20;
case Size.Small: return SMALL_CANDLEHEARTH_COFFEE_CALORIES;
case Size.Medium: return MEDIUM_CANDLEHEARTH_COFFEE_CALORIES;
case Size.Large: return LARGE_CANDLEHEARTH_COFFEE_CALORIES;
default: throw new NotImplementedException($"Unknown size {Size}");
}
}
Expand All @@ -68,6 +93,7 @@ public bool Ice
set
{
ice = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Ice"));
if (ice)
{
specialInstructions.Add("Add ice");
Expand All @@ -92,6 +118,7 @@ public bool RoomForCream
set
{
roomForCream = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("RoomForCream"));
if (roomForCream)
{
specialInstructions.Add("Add cream");
Expand All @@ -116,6 +143,7 @@ public bool Decaf
set
{
decaf = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Decaf"));
}
}

Expand Down
11 changes: 10 additions & 1 deletion Data/Drinks/Drink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using BleakwindBuffet.Data.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;

namespace BleakwindBuffet.Data.Drinks
Expand All @@ -16,11 +18,17 @@ namespace BleakwindBuffet.Data.Drinks
/// </summary>
public abstract class Drink
{
//public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Size of a drink, all drinks have same size options (so virtual)
/// </summary>
protected Size size = Size.Small;
public virtual Size Size { get { return size; } set { size = value; } }
public virtual Size Size { get { return size; }
set
{
size = value;
}
}

/// <summary>
/// Price of a drink, always overriding these (so abstract)
Expand All @@ -37,5 +45,6 @@ public abstract class Drink
/// Special instructions for a drink, always overriding these (so abstract)
/// </summary>
public abstract List<string> SpecialInstructions { get; }

}
}
40 changes: 33 additions & 7 deletions Data/Drinks/MarkarthMilk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,40 @@
using BleakwindBuffet.Data.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace BleakwindBuffet.Data.Drinks
{
/// <summary>
/// Class defining a MarkarthMilk object
/// </summary>
public class MarkarthMilk : Drink, IOrderItem
public class MarkarthMilk : Drink, IOrderItem, INotifyPropertyChanged
{
public const double SMALL_MARKARTH_MILK_PRICE = 1.05;
public const double MEDIUM_MARKARTH_MILK_PRICE = 1.11;
public const double LARGE_MARKARTH_MILK_PRICE = 1.22;
public const uint SMALL_MARKARTH_MILK_CALORIES = 56;
public const uint MEDIUM_MARKARTH_MILK_CALORIES = 72;
public const uint LARGE_MARKARTH_MILK_CALORIES = 93;

public event PropertyChangedEventHandler PropertyChanged;

private new Size size = Size.Small;
public override Size Size
{
get { return size; }
set
{
size = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Size"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Price"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Calories"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialInstructions"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ToString"));
}
}

/// <summary>
/// Gets price of the drink
/// </summary>
Expand All @@ -28,9 +53,9 @@ public override double Price
{
switch (size)
{
case Size.Small: return 1.05;
case Size.Medium: return 1.11;
case Size.Large: return 1.22;
case Size.Small: return SMALL_MARKARTH_MILK_PRICE;
case Size.Medium: return MEDIUM_MARKARTH_MILK_PRICE;
case Size.Large: return LARGE_MARKARTH_MILK_PRICE;
default: throw new NotImplementedException($"Unknown size {Size}");
}
}
Expand All @@ -48,9 +73,9 @@ public override uint Calories
{
switch (size)
{
case Size.Small: return 56;
case Size.Medium: return 72;
case Size.Large: return 93;
case Size.Small: return SMALL_MARKARTH_MILK_CALORIES;
case Size.Medium: return MEDIUM_MARKARTH_MILK_CALORIES;
case Size.Large: return LARGE_MARKARTH_MILK_CALORIES;
default: throw new NotImplementedException($"Unknown size {Size}");
}
}
Expand All @@ -68,6 +93,7 @@ public bool Ice
set
{
ice = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Ice"));
if (ice)
{
specialInstructions.Add("Add ice");
Expand Down
47 changes: 39 additions & 8 deletions Data/Drinks/SailorSoda.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,40 @@
using BleakwindBuffet.Data.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace BleakwindBuffet.Data.Drinks
{
/// <summary>
/// Class defining a SailorSoda object
/// </summary>
public class SailorSoda : Drink, IOrderItem
public class SailorSoda : Drink, IOrderItem, INotifyPropertyChanged
{
public const double SMALL_SAILOR_SODA_PRICE = 1.42;
public const double MEDIUM_SAILOR_SODA_PRICE = 1.74;
public const double LARGE_SAILOR_SODA_PRICE = 2.07;
public const uint SMALL_SAILOR_SODA_CALORIES = 117;
public const uint MEDIUM_SAILOR_SODA_CALORIES = 153;
public const uint LARGE_SAILOR_SODA_CALORIES = 205;

public event PropertyChangedEventHandler PropertyChanged;

private new Size size = Size.Small;
public override Size Size
{
get { return size; }
set
{
size = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Size"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Price"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Calories"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialInstructions"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ToString"));
}
}

/// <summary>
/// Gets price of the drink
/// </summary>
Expand All @@ -28,9 +53,9 @@ public override double Price
{
switch (size)
{
case Size.Small: return 1.42;
case Size.Medium: return 1.74;
case Size.Large: return 2.07;
case Size.Small: return SMALL_SAILOR_SODA_PRICE;
case Size.Medium: return MEDIUM_SAILOR_SODA_PRICE;
case Size.Large: return LARGE_SAILOR_SODA_PRICE;
default: throw new NotImplementedException($"Unknown size {Size}");
}
}
Expand All @@ -48,9 +73,9 @@ public override uint Calories
{
switch (size)
{
case Size.Small: return 117;
case Size.Medium: return 153;
case Size.Large: return 205;
case Size.Small: return SMALL_SAILOR_SODA_CALORIES;
case Size.Medium: return MEDIUM_SAILOR_SODA_CALORIES;
case Size.Large: return LARGE_SAILOR_SODA_CALORIES;
default: throw new NotImplementedException($"Unknown size {Size}");
}
}
Expand All @@ -68,6 +93,7 @@ public bool Ice
set
{
ice = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Ice"));
if (!ice)
{
specialInstructions.Add("Hold ice");
Expand All @@ -85,7 +111,12 @@ public bool Ice
public SodaFlavor Flavor
{
get { return flavor; }
set { flavor = value; }
set
{
flavor = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Flavor"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ToString"));
}
}

/// <summary>
Expand Down
Loading

0 comments on commit 7bbee24

Please sign in to comment.