blob: b8abcc72c5d63a90fb4732c48ca07efe83d99a08 (
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
62
63
64
65
66
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");
}
}
}
|