コード例 #1
0
        public static void Menu(CashRegister Reg)
        {
            bool Cont = true;

            while (Cont)
            {
                Console.WriteLine("-----------------------");
                Console.WriteLine("Press 1 to Scan products");
                Console.WriteLine("Press 2 to view the current total price");
                Console.WriteLine("Press any key to Checkout");

                switch (Console.ReadLine())
                {
                case "1":
                    AddProducts(Reg);
                    continue;

                case "2":
                    Console.WriteLine($"Total items sacnned: {Reg.Products.Count}");
                    Console.WriteLine($"TotalPrice for the scanned products is: {Reg.TotalPrice} £");
                    continue;

                default:
                    //Print Receipt Method
                    Checkout(Reg);
                    Cont = false;
                    break;
                }
            }
        }
コード例 #2
0
        private static void Checkout(CashRegister Reg)
        {
            Console.WriteLine("-------------------------------------RECEIPT------------------------------");
            Console.WriteLine("--------------------------------------------------------------------------");
            Console.WriteLine("ProductName \t   Quantity  \t Weight  \t Price");

            Reg.Receipt();
            Console.WriteLine($"Total Price: {Reg.TotalPrice}");
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.Red;
            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine("Welcome to the Checkout");

            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;

            CashRegister Reg = new CashRegister();


            Menu(Reg);
        }
コード例 #4
0
        public static void AddProducts(CashRegister Reg)
        {
            bool cont = true;

            while (cont)
            {
                Console.WriteLine("Please define the product's name");
                string ProductName = Console.ReadLine();

                Console.WriteLine("Please define the product's price per item/kg");
                double Product = double.Parse(Console.ReadLine());

                Console.WriteLine("Please define the product's weight");
                double Weight = double.Parse(Console.ReadLine());

                if (Weight > 0)
                {
                    Reg.Scan(new Product(ProductName, Product, Weight));


                    Console.WriteLine("ProductName \t   Quantity \t Weight \t Price");
                    Reg.PrintItem(new Product(ProductName, Product, Weight));
                }
                else
                {
                    Console.WriteLine("Please define the quantity of the product");
                    int Quant = int.Parse(Console.ReadLine());
                    Reg.Scan(new Product(ProductName, Product, Quant));


                    Console.WriteLine("ProductName \t  Quantity \t Weight \t Price");
                    Reg.PrintItem(new Product(ProductName, Product, Quant));
                }


                Console.WriteLine("Press Enter to continue or type EXIT to return to the main menu");
                string Option = Console.ReadLine();

                if (Option == "EXIT")
                {
                    cont = false;
                }
            }
        }