예제 #1
0
        public static Carro MontarCarro(string tipo)
        {
            CarroFactory cf = null;

            switch (tipo)
            {
            case "Luxo":
                cf = new CarroLuxoFactory();
                break;

            case "Popular":
                cf = new CarroPopularFactory();
                break;

            default:
                cf = new CarroPopularFactory();
                break;
            }

            Carro carro = new Carro();

            carro.Roda = cf.MontarRoda();
            carro.Som  = cf.MontarSom();

            return(carro);
        }
예제 #2
0
        public static Carro Escolha(string escolha)
        {
            CarroFactory fact = null;

            switch (escolha)
            {
            case "luxo":
                fact = new CarroLuxoFactory();
                break;

            case "popular":
                fact = new CarroPopularFactory();
                break;
            }

            return(new Carro {
                Roda = fact.MontarRoda(),
                Som = fact.MontarSom()
            });
        }
        public static Carro MontarCarro(string tipo)
        {
            CarroFactory factory = null;

            switch (tipo)
            {
            case "LUXO":
                factory = new CarroLuxoFacotry();
                break;

            case "POPULAR":
                factory = new CarroPopularFactory();
                break;
            }

            Carro carro = new Carro();

            carro.roda = factory?.MontarRoda();
            carro.som  = factory?.MontarSom();

            return(carro);
        }