Esempio n. 1
0
        // This had to change, it should also consider the class!
        public float getPrice(int tfe, UIClass typeClass)
        {
            switch (typeClass)
            {
            case UIClass.FirstClass:
                return(PricingTable.getPrice(tfe, 3));

            default:
                return(PricingTable.getPrice(tfe, 0));
            }
        }
Esempio n. 2
0
        private void handlePayment(UIInfo info)
        {
            // Get number of tariefeenheden
            int tariefeenheden = Tariefeenheden.getTariefeenheden(info.From, info.To)
                                 // Get price
                                 float price = PricingTable.getPrice(tariefeenheden, getColumn(info));

            if (info.Way == UIWay.Return)
            {
                price *= 2;
            }
            //Initialize payment
            paymethod(price, info.Payment);
        }
Esempio n. 3
0
        public static float getPrice(Ticket info)
        {
            // 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 Class.FirstClass:
                tableColumn = 3;
                break;

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

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

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

            if (info.Way == Way.Return)
            {
                price *= 2;
            }
            // Add 50 cent if paying with credit card
            if (info.Payment == Payment.CreditCard)
            {
                price += 0.50f;
            }
            return(price);
        }
Esempio n. 4
0
        public float getPrice(UIInfo info)
        {
            int   tableColumn    = getColumn(info);
            int   tariefeenheden = Tariefeenheden.getTariefeenheden(info.From, info.To);
            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;
            }

            return(price);
        }
Esempio n. 5
0
        public static float calcPrice(Ticket ticket, UIDiscount discount, UIPayment payment)
        {
            float price          = 0;
            int   tariefeenheden = Tariefeenheden.getTariefeenheden(ticket.from, ticket.to);
            int   tableColumn;

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

            default:
                tableColumn = 0;
                break;
            }

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

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

            // Get price
            price = PricingTable.getPrice(tariefeenheden, tableColumn);
            if (ticket.way == UIWay.Return)
            {
                price *= 2;
            }
            // Add 50 cent if paying with credit card
            if (payment == UIPayment.CreditCard)
            {
                price += 0.50f;
            }

            return(price);
        }
Esempio n. 6
0
        public float GetCost()
        {
            // Get number of tariefeenheden
            int tariefeenheden = Tariefeenheden.getTariefeenheden(from, to);
            // Compute the column in the table based on choices
            int tableColumn;

            // First based on class
            tableColumn = seatClass.GetColumn();
            // Then, on the discount
            tableColumn = discount.AddDiscount(tableColumn);

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

            if (way == UIWay.Return)
            {
                price *= 2;
            }
            return(price);
        }
Esempio n. 7
0
File: UI.cs Progetto: DvanLaar/MSO
        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 = getColumn(info);

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

            if (info.Way == UIWay.Return)
            {
                price *= 2;
            }

            makePayment(info.Payment, price);
        }
Esempio n. 8
0
        public static float Calculate(int tariefeenheden, UIDiscount discount)
        {
            int col;

            switch (discount)
            {
            default:
            case UIDiscount.NoDiscount:
                col = 0;
                break;

            case UIDiscount.TwentyDiscount:
                col = 1;
                break;

            case UIDiscount.FortyDiscount:
                col = 2;
                break;
            }

            return(PricingTable.getPrice(tariefeenheden, col));
        }
Esempio n. 9
0
        public GetPrice(UIClass klasse, UIDiscount discount, String destination, String origin, UIWay way)
        {
            // Get number of tariefeenheden
            int tariefeenheden = Tariefeenheden.getTariefeenheden(origin, destination);

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

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

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

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

            // Get price
            price = PricingTable.getPrice(tariefeenheden, tableColumn);
            if (way == UIWay.Return)
            {
                price *= 2;
            }
        }
Esempio n. 10
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;
            }
        }