public void DriveCar() { Console.WriteLine("List of cars (EVCs) => "); Dictionary <string, ElectricVehicleCharger> evcs = DBManager.S_Instance.GetAllElectricVehicleChargers(); evcs.Values.ToList().ForEach(b => Console.WriteLine($"ID: {b.BatteryID} MaxPower: {b.MaxPower} Mode: {b.Mode} MaxCapacity: {b.MaxCapacity} CurrentCapacity: {b.CurrentCapacity} Mode: {b.Mode}")); Console.WriteLine("Car ID (EVC-Battery ID): "); string id = Console.ReadLine(); if (evcs.ContainsKey(id)) { double drivingHours = 0; while (true) { Console.WriteLine($"You can drive for {evcs[id].CurrentCapacity} hours."); Console.WriteLine("For how long will you drive?"); Double.TryParse(Console.ReadLine(), out drivingHours); if (evcs[id].CurrentCapacity - drivingHours >= 0) { break; } else { Console.WriteLine("You can not drive for that long."); } } MenuFunctions.StartDriving(evcs[id], drivingHours); Console.WriteLine($"EVC ID: {evcs[id].BatteryID} - {drivingHours} hour(s) drive started."); } else { Console.WriteLine("EVC with that ID doesn't exist."); } }
public void ChangeEVCCharging() { Console.WriteLine("List of EVCs => "); Dictionary <string, ElectricVehicleCharger> evcs = DBManager.S_Instance.GetAllElectricVehicleChargers(); evcs.Values.ToList().ForEach(b => Console.WriteLine($"ID: {b.BatteryID} MaxPower: {b.MaxPower} MaxCapacity: {b.MaxCapacity} CurrentCapacity: {b.CurrentCapacity} Mode: {b.Mode} OnCharger: {b.OnCharger}")); Console.WriteLine("EVC-Battery ID: "); string id = Console.ReadLine(); if (evcs.ContainsKey(id)) { ElectricVehicleCharger currentEVC = DBManager.S_Instance.GetSingleElectricVehicleCharger(id); Console.WriteLine("Do you want to:"); Console.WriteLine("1) Connect evc to charger"); Console.WriteLine("2) Disconnect evc from charger"); Console.WriteLine("3) Start charging"); Console.WriteLine("4) Stop charging"); Console.WriteLine(); Console.WriteLine("Your answer: "); Int32.TryParse(Console.ReadLine(), out int answer2); switch (answer2) { case 1: { if (currentEVC.OnCharger) { Console.WriteLine($"Battery with ID: {id} is already connected."); } else { MenuFunctions.ConnectEVC(currentEVC); Console.WriteLine($"EVC ID: {currentEVC.BatteryID} updated successfully."); } break; } case 2: { if (currentEVC.OnCharger) { Console.WriteLine($"Battery with ID: {id} is already disconnected."); } else { MenuFunctions.DisconnectEVC(currentEVC); Console.WriteLine($"EVC ID: {currentEVC.BatteryID} updated successfully."); } break; } case 3: { if (currentEVC.OnCharger) { MenuFunctions.StartCharging(currentEVC); Console.WriteLine($"EVC ID: {currentEVC.BatteryID} updated successfully."); } else { Console.WriteLine($"EVC-battery with ID: {id} because it is not connected to a charger."); } break; } case 4: { if (currentEVC.OnCharger) { MenuFunctions.StopCharging(currentEVC); Console.WriteLine($"EVC ID: {currentEVC.BatteryID} updated successfully."); } else { Console.WriteLine($"EVC-battery with ID: {id} because it is not connected to a charger."); } break; } default: { Console.WriteLine("Your answer is NOT VALID !"); break; } } } else { Console.WriteLine("EVC with that ID doesn't exist."); } }