private static void UnParkVehicleToGarage(GarageHandler garagehandler) { Console.WriteLine("Please Specify which Vehicle to be unParked"); string regno = Console.ReadLine(); garagehandler.UnParkVehicle(regno); }
private static void FindVehiclesbasedonProperties(GarageHandler garagehandler) { string searchinput = Util.AskForString("Do you want to searchbased on " + " color " + " wheels " + " both "); if (Enum.IsDefined(typeof(optiontypes), searchinput)) { switch (searchinput.ToLower()) { case "color": string coloroption = Util.AskForString("based on which color you want to search"); garagehandler.Findbaseonproperty('C', coloroption, 0); break; case "wheels": int noofwheelsoption = Util.AskForInt("based on how many no of wheels you want to search"); garagehandler.Findbaseonproperty('W', "all", noofwheelsoption); break; case "both": string bothcolor = Util.AskForString("please specify color"); int bothwheels = Util.AskForInt("please specify how many wheels"); garagehandler.Findbaseonproperty('B', bothcolor, bothwheels); break; default: Console.WriteLine("please enter either color or wheels or both"); break; } } else { Console.WriteLine($"you have enter value:{searchinput}. please enter valid input" + $" car or wheels or both"); Console.WriteLine(); } }
private static void ParkVehicleToGarage(GarageHandler garagehandler) { string Vehicletype = Util.AskForString("Please Specify which Vehicle to be Parked" + "\nAirplane" + "\nMotorCycle" + "\nCar" + "\nBus" + "\nBoat"); if (Enum.IsDefined(typeof(vehicletypes), Vehicletype)) { string regNo = Util.AskForString("Reg No of the Vehicle"); string color = Util.AskForString("Color of the Vehicle"); int noofwheels = Util.AskForInt("number of wheels"); switch (Vehicletype.ToLower()) { case "airplane": int noofengines = Util.AskForInt("number of Engines of airplane"); var airplane = new Airplane(regNo, color, noofwheels, noofengines); garagehandler.ParkVehicle(airplane); break; case "motorcycle": int cylindervolume = Util.AskForInt("CylinderVolume of motorcycle"); var motorcycle = new Motorcycle(regNo, color, noofwheels, cylindervolume); garagehandler.ParkVehicle(motorcycle); break; case "car": string fueltype = Util.AskForString("FuelType of car"); var car = new Car(regNo, color, noofwheels, fueltype); garagehandler.ParkVehicle(car); break; case "bus": int noofseats = Util.AskForInt("No of Seats in bus"); var bus = new Bus(regNo, color, noofwheels, noofseats); garagehandler.ParkVehicle(bus); break; case "boat": int length = Util.AskForInt("Length of boat"); var boat = new Boat(regNo, color, noofwheels, length); garagehandler.ParkVehicle(boat); break; default: break; } } else { Console.WriteLine($"you have enter value:{Vehicletype}. please enter valid input"); Console.WriteLine(); } }
private static void UnParkVehicleToGarage(GarageHandler garagehandler) { string regno = Util.AskForString("Please Specify Reg No of Vehicle to be unParked"); garagehandler.UnParkVehicle(regno); }
internal static void Run() { var garagehandler = new GarageHandler(); int capacity = Util.AskForInt("Please Enter Capacity of Garage to be created: "); garagehandler.CreateGarage(capacity); bool ExitProgram = false; while (!ExitProgram) { Console.WriteLine("Please Insert through the menu by inputting the number \n(1, 2, 3 ,4,5, 0) of your choice" + "\n1. park the Vehicles" + "\n2. Unpark the Vehicle" + "\n3. List all vehicles parked" + "\n4. Find Vehicles based on Properties " + "\n5. Search based on regno" + "\n0. Exit the application"); char input = ' '; try { input = Console.ReadLine()[0]; } catch (Exception) { Console.WriteLine("Enter valid value beteen 0 to 5"); } switch (input) { case '1': ParkVehicleToGarage(garagehandler); break; case '2': UnParkVehicleToGarage(garagehandler); break; case '3': ListAllVehiclesParked(garagehandler); break; case '4': FindVehiclesbasedonProperties(garagehandler); break; case '5': FindVehiclebasedonregno(garagehandler); break; case '0': ExitProgram = true; break; default: Console.WriteLine($"An unexpected input menu ({input})" + $"Enter valid value between 0 to 5 "); break; } } }
private static void ListAllVehiclesParked(GarageHandler garagehandler) { garagehandler.Listallvehicles(); }
private static void FindVehiclebasedonregno(GarageHandler garagehandler) { string regno = Util.AskForString("Please Specify Reg No of Vehicle to be searched"); garagehandler.Findbaseonregno(regno); }
private static void ParkVehicleToGarage(GarageHandler garagehandler) { Console.WriteLine("Please Specify which Vehicle to be Parked" + "\nAirplane" + "\nMotorCycle" + "\nCar" + "\nBus" + "\nBoat"); string Vehicletype = Console.ReadLine(); Console.WriteLine("Please specify Reg No of the Vehicle"); string regNo = Console.ReadLine(); Console.WriteLine("Please specify Color of the Vehicle"); string color = Console.ReadLine(); Console.WriteLine("Please specify number of wheels"); string noofwheels = Console.ReadLine(); switch (Vehicletype.ToLower()) { case "airplane": Console.WriteLine("Please specify number of Engines"); string noofengines = Console.ReadLine(); var airplane = new Airplane(regNo, color, int.Parse(noofwheels), int.Parse(noofengines)); garagehandler.ParkVehicle(airplane); break; case "motorcycle": Console.WriteLine("Please specify CylinderVolume"); string cylindervolume = Console.ReadLine(); var motorcycle = new Motorcycle(regNo, color, int.Parse(noofwheels), int.Parse(cylindervolume)); garagehandler.ParkVehicle(motorcycle); break; case "car": Console.WriteLine("Please specify FuelType"); string fueltype = Console.ReadLine(); var car = new Car(regNo, color, int.Parse(noofwheels), fueltype); garagehandler.ParkVehicle(car); break; case "bus": Console.WriteLine("Please specify No of Seats"); string noofseats = Console.ReadLine(); var bus = new Bus(regNo, color, int.Parse(noofwheels), int.Parse(noofseats)); garagehandler.ParkVehicle(bus); break; case "boat": Console.WriteLine("Please specify Length"); string length = Console.ReadLine(); var boat = new Boat(regNo, color, int.Parse(noofwheels), int.Parse(length)); garagehandler.ParkVehicle(boat); break; default: break; } }
internal static void Run() { Console.WriteLine("Please Enter Capacity of Garage to be created"); int capacity = int.Parse(Console.ReadLine()); var garagehandler = new GarageHandler(); garagehandler.CreateGarage(capacity); bool ExitProgram = false; while (!ExitProgram) { Console.WriteLine("Please Insert through the menu by inputting the number \n(1, 2, 3 ,4,5,6,7, 0) of your choice" + "\n1. park the Vehicles" + "\n2. Unpark the Vehicle" + "\n3. List all vehicles parked" + "\n4. Setting maximum capacity of garage" + "\n5. Find Vehicles based on Properties " + "\n6. Search based on regno" + "\n0. Exit the application"); char input = ' '; //Creates the character input to be used with the switch-case below. try { input = Console.ReadLine()[0]; //Tries to set input to the first char in an input line } catch (IndexOutOfRangeException) //If the input line is empty, we ask the users for some input. { Console.Clear(); Console.WriteLine("Please enter some input!"); } switch (input) { case '1': ParkVehicleToGarage(garagehandler); break; case '2': UnParkVehicleToGarage(garagehandler); break; // case '3': // ListAllVehiclesParked(); // break; // case '4': // SettingGarageMaxCapacity(); // break; // case '5': // FindVehiclesbasedonProperties(); // break; // case '6': // FindVehiclebasedonregno(); // break; case '0': ExitProgram = true; break; default: break; } } }