Exemplo n.º 1
0
 static void Main()
 {
     var car = new Car("Лада", 'D') { Color = Color.DarkViolet };
     try
     {
         Console.WriteLine(car.CarPassport.Owner.Name);
     }
     catch
     {
         // ignored
     }
     var driver = new Driver("Вольдемар", 2002) { Category = "BC" };
     car.ChangeOwner(driver, "о777оо");
     driver.Category += 'D';
     car.ChangeOwner(driver, "о777оо");
     Console.WriteLine(driver.Car.CarNumber);
     Console.WriteLine(car.CarPassport.Owner.Name);
     Console.ReadKey();
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var car = new Car("Лада", "D") { Color = Color.Purple };

            try
            {
                Console.WriteLine($"Владелец: {car.CarPassport.Owner.Name}");
            }
            catch (NullReferenceException exception)
            {
                Console.WriteLine($"Владелец еще не назначен\n{exception.Message}");
            }

            var driver = new Driver("Вольдемар", new DateTime(1996, 10, 5)) { Category = "BC" };

            try
            {
                car.ChangeOwner(driver, "o777oo");
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine(e.Message);
            }

            driver.Category += "D";

            car.ChangeOwner(driver, "o777oo");

            Console.WriteLine($"Номер машины: {car.CarNumber}");

            try
            {
                Console.WriteLine($"Владелец: {car.CarPassport.Owner.Name}");
            }
            catch (NullReferenceException exception)
            {
                Console.WriteLine($"Владелец еще не назначен {exception.Message}");
            }

            Console.ReadKey();
        }