private int AddNewVehicleToSlot(Vehicle newVehicle) { foreach (var s in boxes) { result = s.Add(newVehicle);//if result is true, vehicle was successfully added, if not true a new box instance will be created if (!result) { slotPosition++; if (IsSlotNullOrEmpty()) { boxes[slotPosition] = new ParkingBox(slotPosition); } } else { vehicleCount++; Visualize.TextColor(Visualize.ColorType.Green, "\nAdding "); Visualize.TextColor(Visualize.ColorType.Black, "Vehicle Regnr: "); Visualize.TextColor(Visualize.ColorType.Magenta, $"{newVehicle.Regnr} "); Visualize.TextColor(Visualize.ColorType.Black, ""); Console.ReadKey(); return(slotPosition); } } return(-1); }
public string CreateNewBox(string regnr, int input) { if (IsSlotNullOrEmpty(input)) { boxes[input] = new ParkingBox(input); } return(MoveVehicle(regnr, input)); }
public void CreateNewVehicle(string regnr, VehicleType vehicleType) { Vehicle newVehicle = new Vehicle(regnr, vehicleType); if (IsSlotNullOrEmpty()) { boxes[slotPosition] = new ParkingBox(slotPosition); } slotPosition = AddNewVehicleToSlot(newVehicle); }