From b1eb36d3fbc5012b07489454a7452e8488507f6a Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sun, 21 Feb 2021 14:13:49 +0100 Subject: Initial commit --- Views/CheckOrdersView.cs | 50 +++++++++++++++++++++++++++ Views/MainView.cs | 68 ++++++++++++++++++++++++++++++++++++ Views/OrderPizzaStep1View.cs | 61 ++++++++++++++++++++++++++++++++ Views/OrderPizzaStep2View.cs | 67 ++++++++++++++++++++++++++++++++++++ Views/OrderPizzaStep3View.cs | 58 +++++++++++++++++++++++++++++++ Views/OrderPizzaStep4View.cs | 82 ++++++++++++++++++++++++++++++++++++++++++++ Views/View.cs | 24 +++++++++++++ 7 files changed, 410 insertions(+) create mode 100644 Views/CheckOrdersView.cs create mode 100644 Views/MainView.cs create mode 100644 Views/OrderPizzaStep1View.cs create mode 100644 Views/OrderPizzaStep2View.cs create mode 100644 Views/OrderPizzaStep3View.cs create mode 100644 Views/OrderPizzaStep4View.cs create mode 100644 Views/View.cs (limited to 'Views') diff --git a/Views/CheckOrdersView.cs b/Views/CheckOrdersView.cs new file mode 100644 index 0000000..bedf38f --- /dev/null +++ b/Views/CheckOrdersView.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using KukaPizza.Controllers; +using KukaPizza.Models; + +namespace KukaPizza.Views +{ + public class CheckOrdersView : View + { + private CheckOrdersController _controller; + private List orders; + public CheckOrdersView(CheckOrdersController controller) + { + _controller = controller; + orders = controller.Orders; + Init(_controller); + } + + protected override void Draw() + { + Console.Clear(); + Console.Write( +@"================================================================================ + Your orders +================================================================================ +"); + foreach (var o in orders) + { + Console.WriteLine($" Base pizza: {o.BasePizza.Name}"); + Console.WriteLine($" Extra toppings: {o.ExtraToppingsToString()}"); + Console.WriteLine($" Size: {o.Size}"); + Console.Write("--------------------------------------------------------------------------------"); + } + + Console.WriteLine("\n 0. Go back"); + } + + protected override void Interact() + { + int choice = 0; + + do + { + choice = Console.ReadKey(true).KeyChar; + + Draw(); + } while (choice != '0'); + } + } +} \ No newline at end of file diff --git a/Views/MainView.cs b/Views/MainView.cs new file mode 100644 index 0000000..42f7c91 --- /dev/null +++ b/Views/MainView.cs @@ -0,0 +1,68 @@ +using System; +using KukaPizza.Controllers; + +namespace KukaPizza.Views +{ + public class MainView : View + { + private MainController _controller; + public MainView(MainController controller) + { + _controller = controller; + Init(_controller); + + } + protected override void Draw() + { + Console.Write(@" + + + + __ __ __ ____ +/\ \/\ \ /\ \ /\ _`\ __ +\ \ \/'/' __ __\ \ \/'\ __ \ \ \L\ \/\_\ ____ ____ __ + \ \ , < /\ \/\ \\ \ , < /'__`\ \ \ ,__/\/\ \/\_ ,`\ /\_ ,`\ /'__`\ + \ \ \\`\\ \ \_\ \\ \ \\`\ /\ \L\.\_ \ \ \/ \ \ \/_/ /_\/_/ /_/\ \L\.\_ + \ \_\ \_\ \____/ \ \_\ \_\ \__/.\_\ \ \_\ \ \_\/\____\ /\____\ \__/.\_\ + \/_/\/_/\/___/ \/_/\/_/\/__/\/_/ \/_/ \/_/\/____/ \/____/\/__/\/_/ + + + + + 1. Order a pizza + 2. Check orders + + 0. Exit + + + +================================================================================ + Copyright © 2019 Marcin Zelent & Paulius Klezys +================================================================================"); + } + + protected override void Interact() + { + int choice = 0; + + do + { + choice = Console.ReadKey(true).KeyChar; + + switch (choice) + { + case '1': + _controller.OpenOrderPizza(); + break; + case '2': + _controller.OpenCheckOrders(); + break; + } + + Draw(); + } while (choice != '0'); + + if (choice == '0') _controller.Close(); + } + } +} \ No newline at end of file diff --git a/Views/OrderPizzaStep1View.cs b/Views/OrderPizzaStep1View.cs new file mode 100644 index 0000000..d596fee --- /dev/null +++ b/Views/OrderPizzaStep1View.cs @@ -0,0 +1,61 @@ +using System; +using KukaPizza.Controllers; +using KukaPizza.Models; + +namespace KukaPizza.Views +{ + public class OrderPizzaStep1View : View + { + private static OrderPizzaController _controller; + private Pizza[] pizzas; + + public OrderPizzaStep1View(OrderPizzaController controller) + { + _controller = controller; + pizzas = controller.Pizzas; + Init(_controller); + } + + protected override void Draw() + { + Console.Clear(); + Console.Write( +@"================================================================================ + Step 1. Choose base pizza +================================================================================ + +"); + + for (int i = 0; i < pizzas.Length; i++) + { + Console.WriteLine($" {i + 1}. {pizzas[i].Name} ({pizzas[i].ToppingsToString()}) - {pizzas[i].Price}"); + } + + Console.WriteLine("\n 0. Go back"); + Console.Write($"\nChoose number [0-{pizzas.Length}]: "); + } + + protected override void Interact() + { + string choice = ""; + + do + { + Console.CursorVisible = true; + choice = Console.ReadLine(); + Console.CursorVisible = false; + + if (choice == "") choice = "-1"; + + int choiceInt = Int32.Parse(choice); + if (choiceInt > 0 && choiceInt < pizzas.Length + 1) + { + _controller.ChooseBasePizza(choiceInt - 1); + NavigateTo(typeof(OrderPizzaStep2View)); + } + + Draw(); + } while (choice != "0"); + } + } +} \ No newline at end of file diff --git a/Views/OrderPizzaStep2View.cs b/Views/OrderPizzaStep2View.cs new file mode 100644 index 0000000..b8abcc7 --- /dev/null +++ b/Views/OrderPizzaStep2View.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using KukaPizza.Controllers; +using KukaPizza.Models; + +namespace KukaPizza.Views +{ + public class OrderPizzaStep2View : View + { + private static OrderPizzaController _controller; + private Topping[] toppings; + private List selectedToppings; + public OrderPizzaStep2View(OrderPizzaController controller) + { + _controller = controller; + toppings = _controller.Toppings; + selectedToppings = _controller.SelectedToppings; + Init(_controller); + } + + + protected override void Draw() + { + Console.Clear(); + Console.Write( +@"================================================================================ + Step 2. Add extra toppings +========================================================