void CalculatePrice(NormalTicket ticket) { int tariefeenheden = Tariefeenheden.getTariefeenheden(ticket.From, ticket.To); float p; p = 0.16f * tariefeenheden + 0.82f; // is uit appendix B van Lab 2 if (ticket.Class == 1) { p = p * 1.7f; } if (ticket.International) { p = p + 2f; } if (!ticket.Single) { p = p * 2f; } p *= amount; if (tariefeenheden == 0) { p = 0f; } price = p; }
public static float Calculate(string departure, string destination, UIClass type, UIDiscount discount, bool singleFare) { float ret = 0; int tariefeenheden = Tariefeenheden.getTariefeenheden(departure, destination); switch (type) { case UIClass.FirstClass: ret = FirstClassCalculator.Calculate(tariefeenheden, discount); break; case UIClass.SecondClass: ret = SecondClassCalculator.Calculate(tariefeenheden, discount); break; } if (singleFare) { return(ret); } else { return(ret * 2); } }
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); }
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); }
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); }
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); }
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); }
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); }
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; } }
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; } }
public int getTariefeenheden(UIInfo info) { int tariefeenheden = Tariefeenheden.getTariefeenheden(info.From, info.To); return(tariefeenheden); }
public int getDistance() { tarief_eenheden = Tariefeenheden.getTariefeenheden(dep_station, arr_station); return(tarief_eenheden); }