Beispiel #1
0
 public void payDebit(float price, UIPayment payMethod)
 {
     DebitCard d = new DebitCard();
     d.Connect();
     int dcid = d.BeginTransaction(price);
     d.EndTransaction(dcid);
 }
        public static void startPayment(Ticket ticket, UIDiscount discount, UIPayment payment)
        {
            float price = Pricing.calcPrice(ticket, discount, payment);

            // Pay
            switch (payment)
            {
            case UIPayment.CreditCard:
                CreditCard c = new CreditCard();
                c.Connect();
                int ccid = c.BeginTransaction(price);
                c.EndTransaction(ccid);
                break;

            case UIPayment.DebitCard:
                DebitCard d = new DebitCard();
                d.Connect();
                int dcid = d.BeginTransaction(price);
                d.EndTransaction(dcid);
                break;

            case UIPayment.Cash:
                IKEAMyntAtare2000 coin = new IKEAMyntAtare2000();
                coin.starta();
                coin.betala((int)Math.Round(price * 100));
                coin.stoppa();
                break;
            }
        }
Beispiel #3
0
        public bool startPayment(float price)
        {
            switch (paymenttype)
            {
            case UIPayment.CreditCard:
                CreditCard c = new CreditCard();
                c.Connect();
                int ccid = c.BeginTransaction(price);
                c.EndTransaction(ccid);
                break;

            case UIPayment.DebitCard:
                DebitCard d = new DebitCard();
                d.Connect();
                int dcid = d.BeginTransaction(price);
                d.EndTransaction(dcid);
                break;

            case UIPayment.Cash:
                IKEAMyntAtare2000 coin = new IKEAMyntAtare2000();
                coin.starta();
                coin.betala((int)Math.Round(price * 100));
                coin.stoppa();
                break;
            }
            return(true);
            // This should return false upon failure, but that's not going to happen.
        }
Beispiel #4
0
        private void makePayment(UIPayment payment, float price)
        {
            // Select the correct method of payment
            PaymentStrategy payMethod;

            switch (payment)
            {
            case UIPayment.CreditCard:
                // Add 50 cents if paying by credit card
                price    += 0.50f;
                payMethod = new CreditCard();
                break;

            case UIPayment.DebitCard:
                payMethod = new DebitCard();
                break;

            case UIPayment.Cash:
                payMethod = new CoinEater();
                break;

            default:
                payMethod = null;
                throw new Exception("No payment found");
            }

            // Pay
            payMethod.Pay(price);
        }
Beispiel #5
0
        public void betaling(TicketautomaatInvoer info, float price)
        {
            // Pay
            switch (info.Payment)
            {
            case UIPayment.CreditCard:
                CreditCard c = new CreditCard();
                c.Connect();
                int ccid = c.BeginTransaction(price);
                c.EndTransaction(ccid);
                break;

            case UIPayment.DebitCard:
                DebitCard d = new DebitCard();
                d.Connect();
                int dcid = d.BeginTransaction(price);
                d.EndTransaction(dcid);
                break;

            case UIPayment.Cash:
                IKEAMyntAtare2000 coin = new IKEAMyntAtare2000();
                coin.starta();
                coin.betala(price);
                coin.stoppa();
                break;
            }
        }
Beispiel #6
0
        void Pay()
        {
            Price = (float)Math.Round(Price, 2);
            switch (payment.SelectedIndex)
            {
            case 0:
                CreditCard c = new CreditCard();
                c.Connect();
                Price += 0.5f;
                int ccid = c.BeginTransaction(Price);
                PaymentSuccesful = c.EndTransaction(ccid);
                break;

            case 1:
                DebitCard d = new DebitCard();
                d.Connect();
                int dcid = d.BeginTransaction(Price);
                PaymentSuccesful = d.EndTransaction(dcid);
                break;

            case 2:
                IKEAMyntAtare2000 coin = new IKEAMyntAtare2000();
                coin.starta();
                coin.betala(Price);
                PaymentSuccesful = coin.stoppa(true);     //false
                break;
            }
            PaymentSucces(PaymentSuccesful, Price);
        }
Beispiel #7
0
        private bool betaal(UIPayment betaalmiddel, float prijs)
        {
            IBetaalmiddel fysiekBetaalmiddel = new CreditCard(); // Initialiseer betaalmiddel als CreditCard, anders mogen we geen methodes ervan aanroepen.

            switch (betaalmiddel)
            {
            case UIPayment.CreditCard:
                prijs += 0.50f;
                fysiekBetaalmiddel = new CreditCard();
                break;

            case UIPayment.DebitCard:
                fysiekBetaalmiddel = new DebitCard();
                break;

            case UIPayment.Chipknip:
                fysiekBetaalmiddel = new Chipknip();
                break;

            case UIPayment.Cash:
                fysiekBetaalmiddel = new Cash();
                break;
            }
            fysiekBetaalmiddel.Connect();
            int id = fysiekBetaalmiddel.BeginTransaction(prijs);

            // Return True als de betaling succesvol is afgerond.
            return(fysiekBetaalmiddel.EndTransaction(id));
        }
Beispiel #8
0
        public override void Pay(float price)
        {
            DebitCard d = new DebitCard();

            d.Connect();
            int dcid = d.BeginTransaction(price);

            d.EndTransaction(dcid);
        }
Beispiel #9
0
        public void payDebit(float price, UIPayment payMethod)
        {
            DebitCard d = new DebitCard();

            d.Connect();
            int dcid = d.BeginTransaction(price);

            d.EndTransaction(dcid);
        }
Beispiel #10
0
        public void HandleDebitCard(float price)
        {
            DebitCard d = new DebitCard();

            d.Connect();
            int dcid = d.BeginTransaction(price);

            d.EndTransaction(dcid);
        }
Beispiel #11
0
        private UIInfo getUIInfo()
        {
            Class cls;

            if (firstClass.Checked)
            {
                cls = new FirstClass();
            }
            else
            {
                cls = new SecondClass();
            }

            TicketType way;

            if (oneWay.Checked)
            {
                way = new OneWay();
            }
            else
            {
                way = new Return();
            }

            Discount dis;

            if (twentyDiscount.Checked)
            {
                dis = new TwentyDiscount();
            }
            else if (fortyDiscount.Checked)
            {
                dis = new FortyDiscount();
            }
            else
            {
                dis = new NoDiscount();
            }

            PaymentMethod pment;

            if (payment.SelectedIndex == 0)
            {
                pment = new CreditCard();
            }
            else if (payment.SelectedIndex == 1)
            {
                pment = new DebitCard();
            }
            else
            {
                pment = new CoinMachine();
            }

            return(new UIInfo(Station.findStation(fromBox.SelectedItem.ToString()), Station.findStation(toBox.SelectedItem.ToString()), cls, way, dis, pment));
        }
Beispiel #12
0
        public override string[] Pay()
        {
            string[]  log = new string[8];
            DebitCard d   = new DebitCard();

            d.Connect();
            int dcid = d.BeginTransaction(price);

            d.EndTransaction(dcid);
            log[0] = "success";

            return(log);
        }
Beispiel #13
0
        public void WayofPayment(UIInfo info)
        {
            float    price = prijs.getPrice(info);
            Betaling x     = new CreditCard();

            switch (info.Payment)
            {
            case UIPayment.DebitCard:
                x = new DebitCard();
                break;

            case UIPayment.Cash:
                x = new AdapterCoin();
                break;
            }

            x.HandlePayment(price);
        }
Beispiel #14
0
        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);
        }
 // Pay
 public Payment(Ticket standard, UIInfo info)
 {
     switch (info.Payment) //Changing this in any way whatsoever does get rid of the cases but would just replace it with a different system to determine which method of payyment is used.
     {                     // no other method would make it easier to add extra payment methods, so this might as well stay.
         case UIPayment.CreditCard:
             CreditCard c = new CreditCard();
             c.Connect();
             int ccid = c.BeginTransaction(standard.price);
             c.EndTransaction(ccid);
             break;
         case UIPayment.DebitCard:
             DebitCard d = new DebitCard();
             d.Connect();
             int dcid = d.BeginTransaction(standard.price);
             d.EndTransaction(dcid);
             break;
         case UIPayment.Cash:
             IKEAMyntAtare2000 coin = new IKEAMyntAtare2000();
             coin.starta();
             coin.betala((int)Math.Round(standard.price * 100));
             coin.stoppa();
             break;
     }
 }
Beispiel #16
0
 public DebitPayment()
 {
     d = new DebitCard();
 }
Beispiel #17
0
        private void handlePayment(UIInfo info)
        {
            // *************************************
            // This is the code you need to refactor
            // *************************************

            // Get number of tariefeenheden
            int tariefeenheden = Tariefeenheden.getTariefeenheden(info.From, info.To);

            // Compute the column in the table based on choices
            int tableColumn;

            // First based on class
            switch (info.Class)
            {
            case UIClass.FirstClass:
                tableColumn = 3;
                break;

            default:
                tableColumn = 0;
                break;
            }
            // Then, on the discount
            switch (info.Discount)
            {
            case UIDiscount.TwentyDiscount:
                tableColumn += 1;
                break;

            case UIDiscount.FortyDiscount:
                tableColumn += 2;
                break;
            }

            // Get price
            float price = PricingTable.getPrice(tariefeenheden, tableColumn);

            if (info.Way == UIWay.Return)
            {
                price *= 2;
            }
            // Add 50 cent if paying with credit card
            if (info.Payment == UIPayment.CreditCard)
            {
                price += 0.50f;
            }

            // Pay
            switch (info.Payment)
            {
            case UIPayment.CreditCard:
                CreditCard c = new CreditCard();
                c.Connect();
                int ccid = c.BeginTransaction(price);
                c.EndTransaction(ccid);
                break;

            case UIPayment.DebitCard:
                DebitCard d = new DebitCard();
                d.Connect();
                int dcid = d.BeginTransaction(price);
                d.EndTransaction(dcid);
                break;

            case UIPayment.Cash:
                IKEAMyntAtare2000 coin = new IKEAMyntAtare2000();
                coin.starta();
                coin.betala((int)Math.Round(price * 100));
                coin.stoppa();
                break;
            }
        }
Beispiel #18
0
 public DebitPayment()
 {
     d = new DebitCard();
 }