예제 #1
0
        // 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;
        }
예제 #2
0
        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 + " ");
                }
            }
        }