Пример #1
0
        private void definitievePrijs(TicketautomaatInvoer info)
        {
            // *************************************
            // This is the code you need to refactor
            // *************************************

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

            int tariefeenheden = Track.getTariefeenheden();

            // 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
            Prijsberekening P     = new Prijsberekening();
            float           price = P.getPrice(tariefeenheden, tableColumn);

            if (info.Way == UIWay.Return)
            {
                price *= 2;
            }
            // Add 50 cent if paying with credit card if the price is not 0
            if (info.From == info.To)
            {
                MessageBox.Show("Start location and destination are the same.");
                price = 0;
            }
            else if (info.Payment == UIPayment.CreditCard)
            {
                price += 0.50f;
            }

            // Methode betaling aanroepen
            betaling(info, price);
        }
Пример #2
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;
            }
        }
Пример #3
0
 public void CalcRetour(TicketautomaatInvoer info, float price)
 {
     if (info.Way == UIWay.Return)
     {
         price *= 2;
     }
 }
Пример #4
0
        public void GetDiscount(TicketautomaatInvoer info)
        {
            if (info.Discount == UIDiscount.TwentyDiscount)
            {
                tableColumn += 1;
            }

            if (info.Discount == UIDiscount.FortyDiscount)
            {
                tableColumn += 2;
            }
        }
Пример #5
0
        public void GetClass(TicketautomaatInvoer info)
        {
            if (info.Class == UIClass.FirstClass)
            {
                tableColumn = 3;
            }

            else
            {
                tableColumn = 0;
            }
        }
Пример #6
0
        public void CreditCardFee(TicketautomaatInvoer info, float price)
        {
            if (info.From == info.To)
            {
                price = 0;
            }

            else if (info.Payment == UIPayment.CreditCard)
            {
                price += 0.50f;
            }
        }
Пример #7
0
        public void DefinitievePrijs(TicketautomaatInvoer info)
        {
            // Get number of tariefeenheden
            Database.AddTracks();
            tariefeenheden = Database.GetTariefeenheden(Database.alleTracks, info.From, info.To);

            // Get price
            GetClass(info);
            GetDiscount(info);
            Prijsberekening P     = new Prijsberekening();
            float           price = P.PriceColumn(tariefeenheden, tableColumn);

            CalcRetour(info, price);
            CreditCardFee(info, price);

            // Verwerken betaling
            Ticketautomaat t = new Ticketautomaat();

            t.VerwerkBetaling(info, price);
        }
Пример #8
0
        public void VerwerkBetaling(TicketautomaatInvoer info, float price)
        {
            // Pay
            if (info.Payment == UIPayment.CreditCard)
            {
                HandleCreditCard(price);
            }

            if (info.Payment == UIPayment.DebitCard)
            {
                HandleDebitCard(price);
            }

            if (info.Payment == UIPayment.Cash)
            {
                HandleCash(price);
            }

            // Methode printen aanroepen
            if (price != 0)
            {
                PrintTicket(info);
            }
        }
Пример #9
0
        public void PrintTicket(TicketautomaatInvoer info)
        {
            Printer printer = new Printer();

            printer.PrintTicket(info.From, info.To, info.Class, info.Way, info.Discount, info.Payment);
        }