Exemplo n.º 1
0
        static void Main(string[] args)
        {
            TicketMachine t = new TicketMachine();

            Console.WriteLine("Are you a staff member for SoCS? ");
            string staffMember = Console.ReadLine();
            string Member      = "Yes";

            if (staffMember == Member)
            {
                t.Discount = 1;
            }
            else
            {
                t.Discount = 0;
            }

            Console.WriteLine("Please enter a ticket price: ");
            t.TicketPrice = int.Parse(Console.ReadLine());

            Console.WriteLine("Please enter your money amount: ");
            int amount = Int32.Parse(Console.ReadLine());

            t.insertMoney(amount);

            t.printTicket();

            if (t.Balance >= t.TicketPrice)
            {
                Console.WriteLine("Would you like to print off another additional ticket? Yes or No\n");
                string decision = Console.ReadLine();
                if (decision == "Yes")
                {
                    t.printTicket();
                }
                else
                {
                    Console.WriteLine("Okay. I will display your current balance\n");
                    t.status();
                }
            }
            Console.WriteLine("Do you want to remove all money from the machine? ");
            string decision2 = Console.ReadLine();

            if (decision2 == "Yes")
            {
                t.empty();
            }
            else
            {
                Console.WriteLine($"\nOkay your balance is still £{t.Balance}");
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            TicketMachine t = new TicketMachine();

            t.ticketPrice = 10;
            string choice = "y";

            while (choice == "y")
            {
                Console.WriteLine("Insert money: ");
                string money_input     = Console.ReadLine();
                int    money_input_int = int.Parse(money_input);
                t.insertMoney(money_input_int);

                Console.WriteLine("Enter staff promo code: ");
                string promo       = Console.ReadLine();
                bool   promo_valid = false;
                if (promo == t.promo)
                {
                    promo_valid = true;
                }

                Console.WriteLine("Enter 'print' to print ticket or 'refund' to refund deposit: ");
                string print_input = Console.ReadLine().ToLower();
                if (print_input == "print")
                {
                    t.printTicket(promo_valid);
                }
                if (print_input == "refund")
                {
                    t.refundMoney();
                }

                choice = "";
                while (!(choice == "y" || choice == "n"))
                {
                    Console.WriteLine("Would you like to print another ticket? (Y/N): ");
                    choice = Console.ReadLine().ToLower();
                    if (!(choice == "y" || choice == "n"))
                    {
                        Console.WriteLine("Invalid choice");
                    }
                }
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            TicketMachine t = new TicketMachine();

            Console.WriteLine(t.ticketPrice);
        }