示例#1
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);
        }
示例#2
0
文件: UI.cs 项目: NSavenije/MSO3
 int getColumn(UIInfo info)
 {
     // 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;
      }
      return tableColumn;
 }
 public StandardTicket(UIInfo info)
 {
     this.startingStation = info.From;
     this.destination = info.To;
     this.date = "";
     this.trainClass = determineClass(info.Class);
     this.discount = determineDiscount(info.Discount);
     this.price = calculatePrice(this.startingStation, this.destination,info.Discount,info.Class);
 }
示例#4
0
 private void handlePayment(UIInfo info)
 {
     // *************************************
     // This is the code you need to refactor
     // *************************************
     StandardTicket ticket = new StandardTicket(info);
     Payment payment = new Payment(ticket, info);
     printer = new Printer();
     printer.CreateTicket(info, ticket);
 }
示例#5
0
        private void PaymentExecution(UIInfo info)
        {
            HandlePayment h = new HandlePayment(info);

            TicketList TL = new TicketList();

            //maar nu kunnen er dus nog steeds geen meerdere... hoe fixen we dat?
            Ticket t = new Ticket(info);

            TL.AddTicket(t);
        }
示例#6
0
        public void CreateTicket(UIInfo infoo, Ticket ticket)
        {
            this.date = ticket.date;
            this.price = ticket.price;
            this.trainClass = ticket.trainClass;
            this.startingStation = ticket.startingStation;
            this.destination = ticket.destination;
            this.discount = ticket.discount;

            CreateReceipt(infoo);
            PrintTicket();
        }
示例#7
0
        public Ticket(UIInfo info)
        {
            klasse      = info.Class;
            discount    = info.Discount;
            destination = info.To;
            origin      = info.From;
            way         = info.Way;

            GetPrice g = new GetPrice(klasse, discount, destination, origin, way);

            price = g.ReturnPrice();
        }
示例#8
0
        public Ticket generateTicket(UIInfo info)
        {
            Date     d    = new Date();
            string   date = d.getDate();
            TicketID tID  = new TicketID();
            int      id   = tID.generateID();

            Ticket ticket = new Ticket(info, date, id);

            writeTicketToFile(ticket);

            return(ticket);
        }
示例#9
0
        private void handlePrice(UIInfo info)
        {
            if (info.To.stationID() == info.From.stationID())
            {
                MessageBox.Show("You must choose between two different stations");
                return;
            }
            // Handle calculation of the price
            decimal price = PricingCalculator.calculatePrice(info);

            // Handle payment of the ticket
            handlePayment(info, (float)price);
        }
示例#10
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);
        }
示例#11
0
        private int calcTariefeenheden(UIInfo info)
        {
            int tariefeenheden = new int();

            if (info.From.stationID() < info.To.stationID())
            {
                tariefeenheden = Station.getTariefeenheden(info.To, info.From);
            }
            else
            {
                tariefeenheden = Station.getTariefeenheden(info.From, info.To);
            }
            return(tariefeenheden);
        }
示例#12
0
        private void handlePayment(UIInfo info)
        {
            // *************************************
            // This is the code you need to refactor
            // *************************************

            //This code creates a Ticket with all the information stored in it
            Ticket ticket = new Ticket(info.Class, info.Discount, info.Way, info.From, info.To);
            float  price  = ticket.GetCost();

            //This code sets up a new sale
            Sale sale = new Sale(info.Payment);

            sale.Pay(price);
        }
示例#13
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);
        }
示例#14
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);
        }
示例#15
0
        public bool StampOrNot(UIInfo info)
        {
            if (info.Way == UIWay.Return)
            {
                return(true);
            }

            switch (info.Stamp)
            {
            case UIStamp.YesStamp:
                return(true);

            //print de datum hier bij
            case UIStamp.NoStamp:
                return(false);
                //print hier geen datum bij
            }
            return(false);
        }
示例#16
0
        public HandlePayment(UIInfo info)
        {
            switch (info.Payment)
            {
            case UIPayment.CreditCard:
                //CreditPurchase();
                break;

            case UIPayment.DebitCard:
                //DebitPurchase();
                break;

            case UIPayment.Cash:
                //CoinPurchase();

                break;

            default: break;
            }
        }
示例#17
0
文件: UI.cs 项目: 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);
        }
示例#18
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);
        }
示例#19
0
 // 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;
     }
 }
示例#20
0
文件: UI.cs 项目: Jeswer9/LabThree
 private bool InitializePayment(UIInfo info)
 {
     // Pay
     PaymentFactory paymentFactor = new PaymentFactory();
     return paymentFactor.MakePayment(info.Payment, info.Price);
 }
示例#21
0
文件: UI.cs 项目: Jeswer9/LabThree
 //Handles transaction (payment of product and printing ticket)
 private void HandleTransaction(UIInfo info)
 {
     bool success = InitializePayment(info);
     PrintTicket(success);
 }
示例#22
0
文件: UI.cs 项目: Maxymulator/MSO3
        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;
            }
        }
示例#23
0
文件: UI.cs 项目: NSavenije/MSO3
 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);
 }
示例#24
0
 public void CreateReceipt(UIInfo infoo)
 {
     this.payment = infoo.Payment;
     PrintReceipt();
 }
示例#25
0
 private void handlePayment(UIInfo info)
 {
     Controller.startTransaction(info);
 }
示例#26
0
 public Ticket(UIInfo info, string date, int ticketID)
 {
     this.info     = info;
     this.date     = date;
     this.ticketID = ticketID;
 }
示例#27
0
        public static void startTransaction(UIInfo info)
        {
            Ticket ticket = makeTicket(info.From, info.To, info.Class, info.Way);

            Payment.startPayment(ticket, info.Discount, info.Payment);
        }
示例#28
0
文件: UI.cs 项目: Swendude/mso3
        private void handlePayment(UIInfo info)
        {
            // *************************************
            // This is the code you need to refactor
            // *************************************

            Purchase currentpurchase = new Purchase(info.From, info.To, info.Discount, info.Class, info.Payment);

            currentpurchase.makeTrip(info.To, info.From);
            float total = currentpurchase.calculateTotal(info.Way == UIWay.Return);

            currentpurchase.processPayment(total);


            //// 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;
            //}
        }
示例#29
0
 private void handlePayment(UIInfo info, float price)
 {
     info.Payment.Connect();
     info.Payment.BeginTransaction(price);
     info.Payment.Disconnect();
 }
示例#30
0
        private UIInfo getUIInfo()
        {
            UIClass cls;

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

            UIWay way;

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

            UIDiscount dis;

            if (noDiscount.Checked)
            {
                dis = UIDiscount.NoDiscount;
            }
            else if (twentyDiscount.Checked)
            {
                dis = UIDiscount.TwentyDiscount;
            }
            else
            {
                dis = UIDiscount.FortyDiscount;
            }

            UIPayment pment;

            switch ((string)payment.SelectedItem)
            {
            case "Credit card":
                pment = UIPayment.CreditCard;
                break;

            case "Debit card":
                pment = UIPayment.DebitCard;
                break;

            default:
                pment = UIPayment.Cash;
                break;
            }
            UIInfo info = new UIInfo((string)fromBox.SelectedItem,
                                     (string)toBox.SelectedItem,
                                     cls, way, dis, pment);

            Ticket ticket = new Ticket(info, null, 0);

            ticket.generateTicket(info);

            return(info);
        }
示例#31
0
        public int getTariefeenheden(UIInfo info)
        {
            int tariefeenheden = Tariefeenheden.getTariefeenheden(info.From, info.To);

            return(tariefeenheden);
        }