コード例 #1
0
        public void ViewCar(string CarType)
        {
            ICar car;

            switch (CarType)
            {
            case "Toyota":
                car = new Toyota();
                car.View();
                break;

            case "BMW":
                car = new BMW();
                car.View();
                break;

            case "Audi":
                car = new Audi();
                car.View();
                break;

            default:
                Console.WriteLine("Car type not found");
                break;
            }
        }
コード例 #2
0
        public void ViewToyota()
        {
            Toyota toyota = new Toyota();

            toyota.View();
        }