コード例 #1
0
ファイル: Sale.cs プロジェクト: RobinSikkens/MSO-Lab-3
        public void ProcessPayment(UIInfo info)
        {
            Payment p;
            float tprice = t.price;

            switch (info.Payment)
            {
                default:
                case UIPayment.Cash:
                    p = new CashPayment();
                    break;
                case UIPayment.CreditCard:
                    p = new CreditPayment();
                    tprice += 0.5f;
                    break;
                case UIPayment.DebitCard:
                    p = new DebitPayment();
                    break;
            }

            p.BeginTransaction(t.price);
            bool b = p.EndTransaction();

            if (b) { MessageBox.Show("Your payment has been processed succesfully."); }
            else { MessageBox.Show("Your payment was not processed."); }
            WriteToLog();
            PrintReceipt(date, tprice);
        }
コード例 #2
0
ファイル: PaymentSystem.cs プロジェクト: Sopwafel/MSO-Lab3
        /// <summary>
        /// Handles the payment after all information has been put into the UIInfo object.
        /// TODO: Maybe add a return bool indicating succes or failure.
        /// </summary>
        /// <param name="info"></param>
        public static string[] handlePayment(Ticket info)
        {
            PaymentMethods strategy;

            string[] log = new string[8];

            float price = PricingServer.getPrice(info);

            switch (info.Payment)
            {
            case Payment.CreditCard:
                strategy = new CreditCardPayment(price);
                break;

            case Payment.DebitCard:
                strategy = new DebitCardPayment(price);
                break;

            default:
                // We default to a cash payment
                strategy = new CashPayment(price);
                break;
            }
            strategy.Pay();
            return(log);
        }
コード例 #3
0
ファイル: Ticketautomaat.cs プロジェクト: annemik/mso
        public void HandleCash(float price)
        {
            CashPayment coin = new CashPayment();

            coin.Connect();
            int a = coin.BeginTransaction(price);

            coin.EndTransaction(a);
        }
コード例 #4
0
ファイル: UI.cs プロジェクト: bramboomen/mso3
        private Ticket getUIInfo()
        {
            UIClass cls;
            if (firstClass.Checked)
                cls = UIClass.FirstClass;
            else
                cls = UIClass.SecondClass;

            int way;
            if (oneWay.Checked)
                way = 1;
            else
                way = 2;

            float dis;
            if (noDiscount.Checked)
                dis = 0;
            else if (twentyDiscount.Checked)
                dis = 0.20f;
            else
                dis = 0.40f;

            Payment pment;
            ICard c;
            switch ((string)payment.SelectedItem) {
            case "Credit card":
                pment = new CardPayment(c = new CreditCard());
                break;
            case "Debit card":
                pment = new CardPayment(c = new DebitCard());
                break;
            default:
                pment = new CashPayment();
                break;
            }

            return new Ticket ((string)fromBox.SelectedItem,
                (string)toBox.SelectedItem,
                cls, way, dis, pment);
        }
コード例 #5
0
        public void ProcessPayment(UIInfo info)
        {
            Payment p;
            float   tprice = t.price;

            switch (info.Payment)
            {
            default:
            case UIPayment.Cash:
                p = new CashPayment();
                break;

            case UIPayment.CreditCard:
                p       = new CreditPayment();
                tprice += 0.5f;
                break;

            case UIPayment.DebitCard:
                p = new DebitPayment();
                break;
            }

            p.BeginTransaction(t.price);
            bool b = p.EndTransaction();

            if (b)
            {
                MessageBox.Show("Your payment has been processed succesfully.");
            }
            else
            {
                MessageBox.Show("Your payment was not processed.");
            }
            WriteToLog();
            PrintReceipt(date, tprice);
        }