aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <marcin@zelent.net>2021-02-21 14:13:49 +0100
committermarcinzelent <marcin@zelent.net>2019-12-20 14:21:37 +0100
commitb1eb36d3fbc5012b07489454a7452e8488507f6a (patch)
treef6a9e6e561eabde5b06366a6aeac78df123ca917 /Views/OrderPizzaStep2View.cs
Initial commitHEADmaster
Diffstat (limited to 'Views/OrderPizzaStep2View.cs')
-rw-r--r--Views/OrderPizzaStep2View.cs67
1 files changed, 67 insertions, 0 deletions
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<int> 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
+================================================================================
+
+");
+
+ for (int i = 0; i < toppings.Length; i++)
+ {
+ Console.WriteLine($" [{(selectedToppings.Contains(i + 1) ? 'x' : ' ')}] {i + 1}. {toppings[i].Name} - {toppings[i].Price}");
+ }
+
+ Console.WriteLine($"\n {toppings.Length + 1}. Done\n 0. Go back");
+ Console.Write($"\nChoose number [0-{toppings.Length + 1}]: ");
+ }
+
+ 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 != toppings.Length + 1)
+ _controller.SelectTopping(choiceInt);
+ else if (choiceInt == toppings.Length + 1)
+ {
+ _controller.AddExtraToppings();
+ NavigateTo(typeof(OrderPizzaStep3View));
+ }
+
+ Draw();
+ } while (choice != "0");
+ }
+ }
+} \ No newline at end of file