diff options
author | marcinzelent <marcin@zelent.net> | 2021-02-21 14:13:49 +0100 |
---|---|---|
committer | marcinzelent <marcin@zelent.net> | 2019-12-20 14:21:37 +0100 |
commit | b1eb36d3fbc5012b07489454a7452e8488507f6a (patch) | |
tree | f6a9e6e561eabde5b06366a6aeac78df123ca917 /Views/OrderPizzaStep1View.cs |
Diffstat (limited to 'Views/OrderPizzaStep1View.cs')
-rw-r--r-- | Views/OrderPizzaStep1View.cs | 61 |
1 files changed, 61 insertions, 0 deletions
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 |