Exemplo n.º 1
0
        public static IComputerManufacturer GetManufacturer(string manufacturerName)
        {
            IComputerManufacturer manufacturer;

            switch (manufacturerName)
            {
            case GlobalConstants.HpName:
            {
                manufacturer = new HpManufacturer();
                break;
            }

            case GlobalConstants.DellName:
            {
                manufacturer = new DellManufacturer();
                break;
            }

            default:
            {
                throw new InvalidArgumentException("Invalid manufacturer name");
            }
            }

            return(manufacturer);
        }
Exemplo n.º 2
0
        public Manufacturer Create(string manufacturer)
        {
            Manufacturer computerFactory;

            if (manufacturer == HP)
            {
                computerFactory = new HpManufacturer();
            }
            else if (manufacturer == Dell)
            {
                computerFactory = new DellManufacturer();
            }
            else if (manufacturer == Lenovo)
            {
                computerFactory = new LenovoManufacturer();
            }
            else
            {
                throw new ArgumentException(InvalidManufacturerMessage);
            }

            return(computerFactory);
        }