aboutsummaryrefslogtreecommitdiff
blob: d596feef741b6e27ee7083d97808af81b0e895cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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");
        }
    }
}