/// <summary> /// Adds a car for the given <see cref="Lane"/>. /// If the <see cref="Lane.CarsToBeGenerated"/> is 0 then nothing happens. /// </summary> /// <param name="lane">The selected <see cref="Lane"/>.</param> public void AddCarToLane(Lane lane) { if (lane.CarsToBeGenerated == 0 || !lane.IsEmpty()) return; var randomColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)); var car = new Car((Direction) random.Next(1, 4), randomColor, lane); if (lane.GenerateCar(car)) { lane.CarsToBeGenerated--; lane.CarFlow += 1; } }