// calculate dynamically public void CalculateFlightDetails() { CostOfFlight = Passengers.Count * FlightRoute.BaseCost; ProfitFromFlight = Passengers.Sum(x => x.GetPrice(FlightRoute.BasePrice, FlightRoute.LoyaltyPointsGained)); TotalExpectedBaggage = Passengers.Sum(x => x.AllowedBags); TotalLoyaltyPointsRedeemed = Passengers.OfType <LoyaltyPassenger>().Count(x => x.UsePoints) * Convert.ToInt32(Math.Ceiling(FlightRoute.BasePrice)); TotalLoyaltyPointsAccrued = Passengers.OfType <LoyaltyPassenger>().Count(x => x.UsePoints == false) * FlightRoute.LoyaltyPointsGained; }
public void PassengerExit() { int payload = Limit - Weight; var sumPassenger = Passengers.Sum(x => x.Weight); var dictionary = Passengers.ToDictionary(k => k.Weight, i => i.Name); Console.WriteLine("\nExit: "); foreach (var i in dictionary) { if (payload < sumPassenger) { sumPassenger = sumPassenger - i.Key; Console.Write(i.Value + " "); } } }