//estimates the possible rental costs //displays all cars available to the manager //asks for duration of booking and required sevices #region Cost Estimation public void estimateRentalCost(Guid managerGuid) { int carSelection; int[] serviceSelection = new int[4]; int totalCost; List <Service> availableServices; Console.WriteLine("Select the car your customer wants to rent."); Fleet fleet = xmlManager.getFleetInformation(managerGuid); List <Car> cars = xmlManager.getCarInformation(fleet.FleetId); for (int i = 0; i < cars.Count; i++) { Console.WriteLine("{0}. Status: {1} \t Type: {2} \t Price: {3}", i, cars[i].CarStatus, cars[i].CarType, cars[i].PricePerHour); } carSelection = inputServices.validIntInput("Select the number of the car to be rented."); int rentDuration = inputServices.validIntInput("How long will the car be needed (in hours)?"); Console.WriteLine("Which services are required? Seperate by comma!\n"); availableServices = xmlManager.availableServices(); for (int i = 0; i < availableServices.Count; i++) { Console.Write("{0}. {1} ({2} per booking) \t", i, availableServices[i].Name, availableServices[i].Pricing); } Console.WriteLine("\n"); string s1 = Console.ReadLine(); if (String.IsNullOrEmpty(s1)) { Console.WriteLine("No services selected."); } else { try { int[] selectionArray = s1.Split(',').Select(n => Convert.ToInt32(n)).ToArray(); for (int i = 0; i < selectionArray.Length; i++) { //in case of not a limousine tell user service is unavailable if (availableServices[selectionArray[i]].Name == "Massage" && cars[carSelection].CarType != Car.TypeOfCar.LIMOUSINE) { Console.WriteLine("{0} Service unavailable.", availableServices[selectionArray[i]].Name); serviceSelection[selectionArray[i]] = 0; } else { serviceSelection[selectionArray[i]] = 1; } } } catch (Exception ex) { Console.WriteLine("Invalid input. Start cost estimation over."); return; } } totalCost = CalculateCost(cars[carSelection].PricePerHour, rentDuration, serviceSelection); Console.WriteLine("the estimated total for this rent process will be {0}", totalCost); }