public int GetAvailableSeats(Ride ride, Booking booking) { RideType rideType = GetRideType(ride, booking.PickUp, booking.Drop); int availableSeats = 0; switch (rideType) { case 0: availableSeats = bookingService.AvailableSeats(ride, ride.PickUp, ride.Drop); break; case (RideType)1: availableSeats = bookingService.AvailableSeats(ride, booking.PickUp, ride.Drop); break; case (RideType)2: availableSeats = bookingService.AvailableSeats(ride, ride.PickUp, booking.Drop); break; case (RideType)3: availableSeats = bookingService.AvailableSeats(ride, booking.PickUp, booking.Drop); break; } return(availableSeats); }
/// <summary> /// Parameterized Constructor. /// </summary> /// <param name="rideType">Type of the ride.</param> public InvoiceGenerator(RideType rideType) { /// Initialising the Ride Type as Supported from the ride type class enum this.rideType = rideType; /// Catching the Custom Exception for the invalid ride type- Unsupported from the cab service requirements try { /// Initialising hte default value for the NORMAL Ride Type if (rideType.Equals(RideType.NORMAL)) { this.MINIMUM_COST_PER_KM = 10; this.COST_PER_KM = 1; this.MINIMUM_FARE = 5; } /// Initialising the default value for the PREMIUM Ride Type else if (rideType.Equals(RideType.PREMIUM)) { this.MINIMUM_COST_PER_KM = 15; this.COST_PER_KM = 2; this.MINIMUM_FARE = 20; } } catch (CabInvoiceException) { throw new CabInvoiceException(CabInvoiceException.ExceptionType.INVALID_RIDE_TYPE, "The Passed Ride Type is Not Valid"); } }
public RideTicket(ObjectGuid requesterGuid, uint id, RideType type, int time) { RequesterGuid = requesterGuid; Id = id; Type = type; Time = time; }
public double GetEstimatedFare(int rideTypeId, double distance, int?promocodeId) { try { RideType rideType = _dbContext.RideTypes.FirstOrDefault(x => x.Id == rideTypeId); Settings settings = _dbContext.Settings.FirstOrDefault(); double estimatedFare = rideType.BasicCharges + (distance * rideType.FarePerKM); if (promocodeId.HasValue) { Promocode code = _dbContext.Promocodes.FirstOrDefault(x => x.Id == promocodeId); if (code.Type == PromocodeType.FixedDiscount) { estimatedFare = estimatedFare - code.Discount; } else if (code.Type == PromocodeType.DiscountPercentage) { estimatedFare = estimatedFare * (code.Discount / 100); } } return(estimatedFare); } catch (Exception ex) { Error.LogError(ex); return(0); } }
private static void HandleStartRide(GameSession session, PacketReader packet) { RideType type = (RideType)packet.ReadByte(); int mountId = packet.ReadInt(); packet.ReadLong(); long mountUid = packet.ReadLong(); // [46-0s] (UgcPacketHelper.Ugc()) but client doesn't set this data? if (type == RideType.UseItem && !session.Player.Inventory.Items.ContainsKey(mountUid)) { return; } IFieldObject <Mount> fieldMount = session.FieldManager.RequestFieldObject(new Mount { Type = type, Id = mountId, Uid = mountUid, }); fieldMount.Value.Players[0] = session.FieldPlayer; session.Player.Mount = fieldMount; Packet startPacket = MountPacket.StartRide(session.FieldPlayer); session.FieldManager.BroadcastPacket(startPacket); }
//Creating parameterized constructor of the Invoice Generator Class. public InvoiceGenerator(RideType rideType) { this.rideType = rideType; //Exception handling for the invalid ride type. try { //Checking the ride type is equal Normal or not. if (rideType.Equals(RideType.NORMAL)) { this.costPerKm = 1; this.minimumCostPerKm = 10; this.minimumFare = 5; } /// Initialising the default value for the PREMIUM Ride Type else if (rideType.Equals(RideType.PREMIUM)) { this.minimumCostPerKm = 15; this.costPerKm = 2; this.minimumFare = 20; } } catch (CabInvoiceException) { throw new CabInvoiceException(CabInvoiceException.ExceptionType.INVALID_RIDE_TYPE, "Invalid Ride Type"); } }
protected async Task CreateRide(RideType type = RideType.SoloRide, int minutes = 0) { var request = getCreateRideRequest(type, minutes); //Make request var response = await PostAsync("api/rides/create", request); }
public static void DoInsertRide() { RideType rideType = RideTypeController.FindRideTypeByName(rideData[2]); RideSafety rideSafety = RideSafetyController.FindRideSafetyByName(rideData[4]); int rideDurability, rideForce; Int32.TryParse(rideData[1], out rideDurability); Int32.TryParse(rideData[3], out rideForce); Ride ride = new Ride(); ride.RideName = rideData[0]; ride.RideDurabilityCheckPerWeek = rideDurability; ride.RideTypeId = rideType.Id; ride.RideSafetyId = rideSafety.Id; ride.RideStatus = rideData[5]; ride.RideMaintainStatus = rideData[6]; ride.RideForce = rideForce; ConnectionController.GetInstance().Rides.Add(ride); ConnectionController.GetInstance().SaveChanges(); DoInsertHeader(); DoInsertDetail(); }
public void CalculateFare_IfValidParameters_ReturnsFare(RideType rideType, double expectedFare) { var invoiceGenerator = new InvoiceGenerator(rideType); var result = invoiceGenerator.CalculateFare(2.0, 1); Assert.That(result, Is.EqualTo(expectedFare)); }
public Fan(String name, int prefThrill, int ageGroup, RideType prefType, int prefScenery) { this.name = name; this.prefThrill = prefThrill; this.ageGroup = ageGroup; this.prefType = prefType; this.prefScenery = prefScenery; }
protected PriceRequest getPriceRequest(RideType type = RideType.SoloRide) { return(new PriceRequest() { StartAddress = new Address("Aarhus", 8000, "Søgade", 20), EndAddress = new Address("Åbyhøj", 8230, "Søren Frichs Vej", 20), RideType = type, }); }
public Ride(String name, int thrillLevel, int[] suitableAges, RideType type, int scenery) { this.name = name; this.thrillLevel = thrillLevel; this.suitableAges = suitableAges; this.type = type; this.scenery = scenery; points = 0; }
public void BookRide(Ride ride, string from, string to, int numberOfPassengers) { double price = 0; int viaPointsCount = rideService.GetViaPointsCount(ride); RideType rideType = GetRideType(ride, from, to); if (rideType == 0) { price = ride.Price; } else if (rideType == (RideType)1) { int fromIndex = rideService.GetIndex(ride, from); price = ((ride.Price) / (viaPointsCount + 1)) * (fromIndex + 1); price = Math.Round(price, MidpointRounding.AwayFromZero); } else if (rideType == (RideType)2) { int toIndex = rideService.GetIndex(ride, to); price = ((ride.Price) / (viaPointsCount + 1)) * (toIndex + 1); price = Math.Round(price, MidpointRounding.AwayFromZero); } else { int fromIndex = rideService.GetIndex(ride, from); int toIndex = rideService.GetIndex(ride, to); price = ((ride.Price) / (viaPointsCount + 1)) * (toIndex - fromIndex); price = Math.Round(price, MidpointRounding.AwayFromZero); } if (ride.PublisherId == LoginActions.currentUser.Id) { Console.WriteLine("Sorry!! You cannot book this ride"); Console.WriteLine("Ride Publisher cannot book the ride"); commonMethods.FurtherAction(1); } Booking booking = new Booking() { Id = Guid.NewGuid().ToString(), BookedBy = LoginActions.currentUser.Id, RideId = ride.Id, PickUp = from, Drop = to, Price = price, NumberOfSeatsBooked = numberOfPassengers, Status = (ride.AutoApproveRide) ? (BookingStatus)0 : (BookingStatus)1, }; bookingService.AddBooking(booking); Console.WriteLine("Booking Successful!!!"); if (ride.AutoApproveRide == false) { Console.WriteLine("You can see the booking status at View Your Bookings option in dashboard.."); } commonMethods.FurtherAction(1); }
public void CalculateFare_IfMultipleRidesPassed_ReturnsInvoiceSummary(RideType rideType, double expectedFare) { Ride[] rides = { new Ride(1.0, 1), new Ride(2.0, 1) }; var invoiceGenerator = new InvoiceGenerator(rideType); var result = invoiceGenerator.CalculateFare(rides); var expected = new InvoiceSummary(2, expectedFare); Assert.That(result, Is.EqualTo(expected)); }
/// <summary> /// Calculate the total fare for the given distance and time /// </summary> /// <param name="distance"></param> /// <param name="time"></param> /// <returns></returns> public double CalculateFare(double distance, int time, RideType rideType) { if (rideType.Equals(RideType.NORMAL)) { return(SetType(CostPerKmForNormal, CostPerMinuteForNormal, MinimumFareForNormal, distance, time)); } else { return(SetType(CostPerKmForPremium, CostPerMinuteForPremium, MinimumFareForPremium, distance, time)); } }
private Ride CreateRide(int startLocation, int endLocation, RideType rideType, DateTime time) { return(new Ride { TaxiInfo = FindNearestTaxi(startLocation), StartLocation = startLocation, EndLocation = endLocation, RideType = rideType, Time = time }); }
public void GetInvoiceSummary_WhenPassedUserId_ReturnsInvoiceSummary(RideType rideType, double expectedFare) { Ride[] rides = { new Ride(1.0, 1), new Ride(2.0, 1) }; var invoiceGenerator = new InvoiceGenerator(rideType); var userID = "1"; invoiceGenerator.AddRides(userID, rides); var result = invoiceGenerator.GetInvoiceSummary(userID); var expected = new InvoiceSummary(2, expectedFare); Assert.That(result, Is.EqualTo(expected)); }
protected CreateRideRequest getCreateRideRequest(RideType type = RideType.SoloRide, int minutes = 0) { return(new CreateRideRequest() { ConfirmationDeadline = DateTime.Now.AddSeconds(1).AddMinutes(-minutes), //added one second because those dates must be in the future DepartureTime = DateTime.Now.AddSeconds(1), StartDestination = new Address("City", 8000, "Street", 21), EndDestination = new Address("City", 8000, "Street", 21), RideType = type, PassengerCount = 2 }); }
private static LyftModalDialogViewModel PlusInstance(RideType ride) { return(new LyftModalDialogViewModel() { Image = new BitmapImage(new Uri("ms-appx://29Quizlet/Assets/LyftPlus.png")), Title = "Plus", ShortTitle = "Supersized ride, 6 seats", Description = "A supersized ride when you need more space. Fits up to 6 people.", Minimum = $"{ride.PricingDetails.CostMinimum / 100.0:C}", BaseFare = $"{ride.PricingDetails.BaseCharge / 100.0:C}", PerMile = $"{ride.PricingDetails.CostPerMile / 100.0:C}", PerMinute = $"{ride.PricingDetails.CostPerMinute / 100.0:C}", }); }
[TestCase(null, 0)] //will default to false public void IsShared_WhenSet_ValidatesInput(RideType type, int numberOfErrors) { var request = new CreateRideRequest { RideType = type, DepartureTime = _validDepartureTime, ConfirmationDeadline = _validConfirmationTime, PassengerCount = _validPassengerCount, StartDestination = _validAddress, EndDestination = _validAddress }; Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors)); }
private static LyftModalDialogViewModel LyftInstance(RideType ride) { return(new LyftModalDialogViewModel() { Image = new BitmapImage(new Uri("ms-appx://29Quizlet/Assets/Lyft.png")), Title = "Lyft", ShortTitle = "Fast ride, 4 seats", Description = "A personal ride for when you need to get to your destination fast. Fits up to 4 people.", Minimum = $"{ride.PricingDetails.CostMinimum/100.0:C}", BaseFare = $"{ride.PricingDetails.BaseCharge / 100.0:C}", PerMile = $"{ride.PricingDetails.CostPerMile / 100.0:C}", PerMinute = $"{ride.PricingDetails.CostPerMinute / 100.0:C}", }); }
/// <summary> /// This factory returns a strategy for calculation of a price for a given ride type. /// </summary> /// <param name="type">The type of the ride</param> /// <returns>The strategy used for the given ride</returns> public IPriceStrategy GetPriceStrategy(RideType type) { if (type == RideType.SoloRide) { return(new SoloRideStrategy()); } if (type == RideType.SharedRide) { return(new SharedRideStrategy()); } throw new Exception("Invalid ride type"); }
public Category GetRideValue(RideType rideType) { if (rideType.Equals(RideType.NORMAL)) { return(new Category(10, 1, 5)); } if (rideType.Equals(RideType.PREMIUM)) { return(new Category(15, 2, 20)); } else { return(null); } }
//Calculates the total fare for a particular ride public static double CalculateFare(double distanceInKM, int timeInMin, RideType rideType) { SetCharges(rideType); double calculatedFare = 0; if (distanceInKM <= 0) { throw new CabInvoiceException(CabInvoiceException.ExceptionType.INVALID_DISTANCE, "Invalid Distance"); } if (timeInMin < 0) { throw new CabInvoiceException(CabInvoiceException.ExceptionType.INVALID_TIME, "Invalid Time"); } calculatedFare = (CHARGE_PER_KM * distanceInKM) + (CHARGE_PER_MIN * timeInMin); return(Math.Max(calculatedFare, MINIMUM_FARE)); }
///Parameterized constructor public InvoiceGenerator(RideType rideType) { this.rideRepository = new RideRepository(); this.rideType = rideType; if (rideType.ToString().Equals("NORMAL")) { this.MINIMUM_COST_PER_KM = 10; this.COST_PER_MIN = 1; this.MINIMUM_FARE = 5; } else { this.MINIMUM_COST_PER_KM = 15; this.COST_PER_MIN = 2; this.MINIMUM_FARE = 20; } }
/// <summary> /// Order a ride with the closest taxi to the destination. /// </summary> /// <param name="locationFrom">Location of the customer</param> /// <param name="locationTo">Location of the destination</param> /// <param name="rideType">Within city or between cities</param> /// <param name="time">Time of the order</param> /// <returns></returns> public Ride OrderRide(int locationFrom, int locationTo, RideType rideType, DateTime time) { Taxi closestTaxi = GetClosestTaxi(locationFrom, locationTo); if (closestTaxi == null || Math.Abs(closestTaxi.Location - locationFrom) > DISTANCE_THRESHOLD) { throw new Exception("There are no available taxi vehicles!"); } Ride ride = new Ride { Taxi = closestTaxi, LocationFrom = locationFrom, LocationTo = locationTo, RideType = rideType, Time = time }; Console.WriteLine("Ride ordered, price: " + ride.Price.ToString()); return(ride); }
//private method for setting the charges for a each type of ride private static void SetCharges(RideType rideType) { if (rideType.Equals(RideType.NORMAL)) { CHARGE_PER_KM = 10; CHARGE_PER_MIN = 1; MINIMUM_FARE = 5; } else if (rideType.Equals(RideType.PREMIUM)) { CHARGE_PER_KM = 15; CHARGE_PER_MIN = 2; MINIMUM_FARE = 20; } else { throw new CabInvoiceException(CabInvoiceException.ExceptionType.INVALID_RIDE_TYPE, "Invalid Ride Type"); } }
private async Task <Booking> BikeBooking(Station station, RideType type, int id) { await Task.Delay(500); var booking = new Booking { Id = 222, FromStation = station, ToStation = stations[0], RegistrationDate = DateTime.UtcNow, DueDate = DateTime.UtcNow.AddMinutes(3), EventId = id, BikeId = 2332, RideType = type }; Settings.CurrentBookingId = booking.Id; return(booking); }
private static void HandleStartRide(GameSession session, PacketReader packet) { RideType type = (RideType)packet.ReadByte(); int mountId = packet.ReadInt(); packet.ReadLong(); long mountUid = packet.ReadLong(); // [46-0s] (UgcPacketHelper.Ugc()) but client doesn't set this data? IFieldObject <Mount> fieldMount = session.FieldManager.RequestFieldObject(new Mount { Type = type, Id = mountId, Uid = mountUid }); session.Player.Mount = fieldMount; Packet startPacket = MountPacket.StartRide(session.FieldPlayer); session.FieldManager.BroadcastPacket(startPacket); }
/// <summary> /// Parameterised constructor /// </summary> /// <param name="rideType"></param> public InvoiceGenerator(RideType rideType) { this.rideType = rideType; if (rideType.Equals(RideType.NORMAL)) { this.COST_PER_KM = 10; this.COST_PER_MIN = 1; this.MIN_FARE = 5; } else if (rideType.Equals(RideType.PREMIUM)) { this.COST_PER_KM = 15; this.COST_PER_MIN = 2; this.MIN_FARE = 20; } else { throw new CabInvoiceException(CabInvoiceException.Type.INVALID_RIDE_TYPE, "Ride type is Invalid"); } }