コード例 #1
0
        public override void GetPayment(double grandtotal)
        {
            grandtotal      = Math.Round(grandtotal, 2);
            this.GrandTotal = grandtotal;
            double roundgrandtotal = Math.Round(GrandTotal, 2);

            this.GrandTotal     = roundgrandtotal;
            this.AmountTendered = InputUtil.ReadDouble($"Total is ${grandtotal}\nCash amount: ", grandtotal, 10000);
            this.Change         = this.AmountTendered - grandtotal;
            double roundchange = Math.Round(Change, 2);

            this.Change = roundchange;
        }
コード例 #2
0
        public void RunApp()
        {
            ProductListView plv         = new ProductListView(this.Products);
            bool            continueApp = true;

            while (continueApp)
            {
                Console.Clear();
                Console.WriteLine("Welcome to the POS Console.\n\n");
                plv.Display();
                int     productIndex = InputUtil.ReadInteger("\nPlease select a product", 0, plv.Products.Count - 1);
                Product choice       = plv.Products[productIndex];
                this.ProductAction(choice);
                continueApp = InputUtil.GetYesNo("\nWould you like to purchase another product? (y/n)");
            }
        }
コード例 #3
0
        public void ProductAction(Product choice)
        {
            if (InputUtil.GetYesNo("Would you like to order this item? (y/n)") == false)
            {
                return;
            }

            int qty = InputUtil.ReadInteger("\nHow many would you like?", 0, 25);

            if (qty > 0 && InputUtil.GetYesNo("Add purchase? (y/n)"))
            {
                this.SelectedProducts.AddProduct(choice, qty);
            }

            if (InputUtil.GetYesNo("\nWould you like to check out? (y/n)"))
            {
                int method = InputUtil.ReadInteger(
                    "How are you paying today?\n\t1 = cash\n\t2 = check\n\t3 = charge\n\t4 = cancel", 1, 4);
                PaymentAbstract paymentDetails = null;
                switch (method)
                {
                case 1: paymentDetails = new CashPayment(); break;

                case 2: paymentDetails = new CheckPayment(); break;

                case 3: paymentDetails = new CreditPayment(); break;

                case 4: break;
                }
                if (paymentDetails is null)
                {
                    // user cancelled payment - abort order
                }
                else
                {
                    paymentDetails.GetPayment(SelectedProducts.GetGrandTotal());
                    Console.WriteLine();
                    Console.WriteLine("Receipt:");
                    Receipt rcpt = new Receipt(SelectedProducts, paymentDetails);
                    rcpt.Display();

                    SelectedProducts.Clear();
                }
            }
        }
コード例 #4
0
 public override void GetPayment(double grandtotal)
 {
     grandtotal       = Math.Round(grandtotal, 2);
     this.GrandTotal  = grandtotal;
     this.CheckNumber = InputUtil.GetInputString("Check number: ");
 }