From b1eb36d3fbc5012b07489454a7452e8488507f6a Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sun, 21 Feb 2021 14:13:49 +0100 Subject: Initial commit --- Models/Pizza.cs | 36 ++++++++++++++++++++++++++++++++++++ Models/PizzaOrder.cs | 43 +++++++++++++++++++++++++++++++++++++++++++ Models/Topping.cs | 29 +++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 Models/Pizza.cs create mode 100644 Models/PizzaOrder.cs create mode 100644 Models/Topping.cs (limited to 'Models') diff --git a/Models/Pizza.cs b/Models/Pizza.cs new file mode 100644 index 0000000..6cc053c --- /dev/null +++ b/Models/Pizza.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; + +namespace KukaPizza.Models +{ + public class Pizza + { + private string _name; + private List _toppings; + private double _price; + + public Pizza(string name, List toppings, double price) + { + _name = name; + _toppings = toppings; + _price = price; + } + + public string Name { get { return _name; } } + public List Toppings { get { return _toppings; } } + public double Price { get { return _price; } } + + public string ToppingsToString() + { + string toppings = ""; + + for (int i = 0; i < _toppings.Count - 1; i++) + { + toppings += _toppings[i].Name + ", "; + } + + toppings += _toppings[_toppings.Count - 1].Name; + + return toppings; + } + } +} \ No newline at end of file diff --git a/Models/PizzaOrder.cs b/Models/PizzaOrder.cs new file mode 100644 index 0000000..a8a983a --- /dev/null +++ b/Models/PizzaOrder.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; + +namespace KukaPizza.Models +{ + public enum PizzaSize + { + Small, + Medium, + Large + } + public class PizzaOrder + { + public Pizza BasePizza { get; set; } + public List ExtraToppings { get; set; } + public PizzaSize Size { get; set; } + + public string ExtraToppingsToString() + { + string toppings = ""; + + for (int i = 0; i < ExtraToppings.Count - 1; i++) + { + toppings += ExtraToppings[i].Name + ", "; + } + + toppings += ExtraToppings[ExtraToppings.Count - 1].Name; + + return toppings; + } + + public double GetPrice() + { + double totalPrice = BasePizza.Price; + + foreach (var t in ExtraToppings) + { + totalPrice += t.Price; + } + + return totalPrice; + } + } +} \ No newline at end of file diff --git a/Models/Topping.cs b/Models/Topping.cs new file mode 100644 index 0000000..ab273e3 --- /dev/null +++ b/Models/Topping.cs @@ -0,0 +1,29 @@ +namespace KukaPizza.Models +{ + public enum ToppingCategory + { + Vegetable, + Meat, + Spice, + Cheese, + SeaFood, + Sauce + } + + public class Topping + { + private string _name; + private ToppingCategory _category; + private double _price; + public Topping(string name, ToppingCategory category, double price) + { + _name = name; + _category = category; + _price = price; + } + + public string Name { get { return _name; } } + public ToppingCategory Category { get { return _category; } } + public double Price { get { return _price; } } + } +} \ No newline at end of file -- cgit v1.2.3