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;
        }
예제 #2
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);
        }
예제 #3
0
        public Manufacturer GetManufacturer(string name)
        {
            Manufacturer manufacturer;
            if (name == "HP")
            {
                manufacturer = new HPManufacturer();               
            }
            else if (name == "Dell")
            {
                manufacturer = new DellManufacturer();        
            }
            else if (name == "Lenovo")
            {
                manufacturer = new LenovoManufacturer();
            }
            else
            {
                throw new InvalidArgumentException("Invalid manufacturer!");
            }

            return manufacturer;
        }
예제 #4
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);
        }