Beispiel #1
0
        private void addACar()
        {
            Console.WriteLine("What id do you want to add the car to");
            try
            {
                id = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception)
            {
                Console.WriteLine("Returning to start menu");
                startMenu();
            }

            for (int i = 0; i < persons.Count; i++)
            {
                if (persons[i].Id == id)
                {
                    Car car = new Car();
                    Console.WriteLine("Write the make of the car");
                    car.Make = Console.ReadLine();
                    Console.WriteLine("Write the model of the car");
                    car.Model = Console.ReadLine();
                    Console.WriteLine("What year was the car made");
                    car.Year = Convert.ToInt32(Console.ReadLine());
                    persons[i].AddCar(car);
                }
            }
        }
Beispiel #2
0
 public void AddCar(Car car)
 {
     cars.Add(car);
 }