コード例 #1
0
ファイル: Program.cs プロジェクト: venkatdroid/889866
        static void Main(string[] args)
        {
            CarFactory carFactory = new ConcreteCarFactory();
            CarClient  carClient  = new CarClient(carFactory);

            carClient.BuildMicroCar(Location.USA);
            carClient.BuildMiniCar(Location.USA);
            carClient.BuildLuxuryCar(Location.USA);
            carClient.BuildMiniCar(Location.INDIA);
            carClient.BuildMicroCar(Location.INDIA);
            carClient.BuildLuxuryCar(Location.INDIA);
            carClient.BuildLuxuryCar(Location.DEFAULT);
            carClient.BuildMicroCar(Location.DEFAULT);
            carClient.BuildMiniCar(Location.DEFAULT);
            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            CarFactory carFactory = new ConcreteCarFactory();
            CarClient  carClient  = new CarClient(carFactory);

            Console.WriteLine("Enter the car type (MINI, MICRO, LUXURY)");
            string ip = Console.ReadLine();

            if (ip == "LUXURY")
            {
                carClient.BuildLuxuryCar(Location.DEFAULT, CarType.LUXURY);
            }
            if (ip == "MICRO")
            {
                carClient.BuildMicroCar(Location.USA, CarType.MICRO);
            }
            if (ip == "MINI")
            {
                carClient.BuildMiniCar(Location.INDIA, CarType.MINI);
            }


            Console.Read();
        }