aboutsummaryrefslogtreecommitdiff
blob: b027e7ee30a55b35ad0d979a53a337a401caae70 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using KukaPizza.Controllers;
using KukaPizza.Models;

namespace KukaPizza.Views
{
    public class OrderPizzaStep4View : View
    {
        private OrderPizzaController _controller;
        private PizzaOrder order;

        public OrderPizzaStep4View(OrderPizzaController controller)
        {
            _controller = controller;
            order = _controller.Order;
            Init(_controller);
        }
        protected override void Draw()
        {
            Console.Clear();
            Console.Write(
@"================================================================================
    Step 4. Confirm order
================================================================================

");
            Console.WriteLine($"    Base pizza: {order.BasePizza.Name}");
            Console.WriteLine($"    Extra toppings: {order.ExtraToppingsToString()}");
            Console.WriteLine($"    Size: {order.Size}");
            Console.WriteLine($"    Price: {order.GetPrice()}");

            Console.Write(
@"    
    Do you want to place this order?
    1. Yes, pay with Visa card
    2. Yes, pay with Mastercard card
    3. No, go back
");
            Console.Write($"\nChoose number [1-3]: ");
        }

        protected override void Interact()
        {
            string choice = "";

            do
            {
                Console.CursorVisible = true;
                choice = Console.ReadLine();
                Console.CursorVisible = false;

                if (choice == "1")
                {
                    _controller.MakePaymentWithVisa();
                }
                else if (choice == "2")
                {
                    _controller.MakePaymentWithMastercard();
                }
                else if (choice == "3")
                {
                    _controller.CancelOrder();
                    Console.WriteLine("\nOrder canceled.");
                }

                if (choice == "1" || choice == "2")
                {
                    _controller.ConfirmOrder();
                    Console.WriteLine("\nOrder successfully placed.");
                }

                Console.WriteLine("Press any key to return to the main screen...");
                Console.ReadKey();
                _controller.GoBackToMainView();


                Draw();
            } while (choice != "3");
        }
    }
}