public static void Run() { Highpoint.Sage.SimCore.Model model = new Highpoint.Sage.SimCore.Model(); MotorPool mp = new MotorPool(model); foreach (int passengerCapacity in new[] { 1, 3, 4, 7, 9 }) { mp.Add(new Vehicle(model, passengerCapacity)); } Console.WriteLine("Stocked a motor pool with {0} seat vehicles.\r\n", StringOperations.ToCommasAndAndedList(mp.Resources.Cast <Vehicle>(), vehicle => vehicle.PassengerCapacity.ToString())); foreach (int[] requisitions in new[] { new[] { 1, 3, 4 }, new[] { 2, 5, 7 }, new[] { 1, 5, 8 }, new[] { 8, 1, 6 }, new[] { 8, 7, 6 }, new[] { 1, 3, 4, 7, 8, 9 } }) { Console.WriteLine("\r\nTest:"); List <VehicleRequest> requests = requisitions.Select(requisition => new VehicleRequest(requisition)).ToList(); foreach (VehicleRequest vehicleRequest in requests) { Console.Write("Requested a {0} seat vehicle. ", vehicleRequest.SeatsNeeded); if (vehicleRequest.Acquire(mp, false)) { Console.WriteLine(" Got a vehicle with {0} seats.", ((Vehicle)vehicleRequest.ResourceObtained).PassengerCapacity); } else { Console.WriteLine(" Motor pool had nothing satisfactory."); } } foreach (VehicleRequest vehicleRequest in requests.Where(n => n.ResourceObtained != null)) { vehicleRequest.Release(); } } }