Example #1
0
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            CheckIfComputerExist(computerId);

            if (this.components.Any(x => x.Id == id))
            {
                throw new ArgumentException(ExceptionMessages.ExistingComponentId);
            }

            IComponent component = null;

            switch (componentType)
            {
            case "CentralProcessingUnit": component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation); break;

            case "Motherboard": component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation); break;

            case "PowerSupply": component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation); break;

            case "RandomAccessMemory": component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation); break;

            case "SolidStateDrive": component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation); break;

            case "VideoCard": component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation); break;

            default: throw new ArgumentException(ExceptionMessages.InvalidComponentType);
            }
            IComputer computer = this.computers.FirstOrDefault(x => x.Id == computerId);

            computer.AddComponent(component);
            this.components.Add(component);

            return(string.Format(SuccessMessages.AddedComponent, component.GetType().Name, component.Id, computerId));
        }
Example #2
0
        private IComponent CreateComponent(string componentType, int id, string manufacturer,
                                           string model, decimal price, double overallPerformance,
                                           int generation)
        {
            IComponent component = null;

            if (componentType == "CentralProcessingUnit")
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "Motherboard")
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "PowerSupply")
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "RandomAccessMemory")
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "SolidStateDrive")
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == "VideoCard")
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
            }

            return(component);
        }
Example #3
0
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            var computer = this.computers.FirstOrDefault(x => x.Id == computerId);

            if (computer == null)
            {
                throw new ArgumentException(ExceptionMessages.NotExistingComputerId);
            }

            IComponent component = null;

            if (this.components.Any(x => x.Id == id))
            {
                throw new ArgumentException(ExceptionMessages.ExistingComponentId);
            }

            if (componentType == "CentralProcessingUnit")
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "Motherboard")
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "PowerSupply")
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "RandomAccessMemory")
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "SolidStateDrive")
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else if (componentType == "VideoCard")
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
                computer.AddComponent(component);
                this.components.Add(component);
            }
            else
            {
                throw new ArgumentException(ExceptionMessages.InvalidComponentType);
            }

            return(string.Format(SuccessMessages.AddedComponent, componentType, component.Id, computer.Id));
        }
Example #4
0
 protected Computer(CentralProcessingUnit cpu, RandomAcessMemory ram, IEnumerable<HardDriver> hardDrives, IVideoCard videoCard, IMotherboard motherBoard)
 {
     this.CentralProcessingUnit = cpu;
     this.RandomAcessMemory = ram;
     this.HardDrives = hardDrives;
     this.VideoCard = videoCard;
     this.MotherBoard = motherBoard;
 }
Example #5
0
 protected Computer(CentralProcessingUnit cpu, RandomAcessMemory ram, IEnumerable <HardDriver> hardDrives, IVideoCard videoCard, IMotherboard motherBoard)
 {
     this.CentralProcessingUnit = cpu;
     this.RandomAcessMemory     = ram;
     this.HardDrives            = hardDrives;
     this.VideoCard             = videoCard;
     this.MotherBoard           = motherBoard;
 }
Example #6
0
        private ICentralProcessingUnit BuildCPU(IArithmeticLogicUnit alu, IMemoryManagementUnit mmu, ISystemBridge bridge)
        {
            IInstructionConfigurator configurator = new InstructionConfigurator(bridge);
            IInstructionParser       parser       = new InstructionParser(configurator);
            InstructionReader        reader       = new InstructionReader(mmu, alu.IP);
            ICentralProcessingUnit   cpu          = new CentralProcessingUnit(alu, parser, reader);

            return(cpu);
        }
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            if (!IsComputerExist(computerId))
            {
                throw new ArgumentException("Computer with this id does not exist.");
            }

            if (components.Any(x => x.Id == id))
            {
                throw new ArgumentException("Component with this id already exists.");
            }

            IComponent component = null;

            if (componentType == "CentralProcessingUnit")
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "Motherboard")
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "PowerSupply")
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "RandomAccessMemory")
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "SolidStateDrive")
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
            }

            else if (componentType == "VideoCard")
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
            }

            else
            {
                throw new ArgumentException("Component type is invalid.");
            }

            var computer = computers.FirstOrDefault(c => c.Id == computerId);

            computer.AddComponent(component);
            components.Add(component);

            return($"Component {component.GetType().Name} with id {component.Id} added successfully in computer with id {computer.Id}.");
        }
Example #8
0
        private IComponent CreateComponent(int id, string componentType,
                                           string manufacturer, string model,
                                           decimal price, double overallPerformance,
                                           int generation)
        {
            Type type = GetDefaultType(componentType);

            if (type == null)
            {
                throw new ArgumentException
                          (ExceptionMessages.InvalidComponentType);
            }

            IComponent component = null;

            if (componentType
                == ComponentType.CentralProcessingUnit.ToString())
            {
                component = new CentralProcessingUnit(id, manufacturer,
                                                      model, price, overallPerformance, generation);
            }
            if (componentType
                == ComponentType.Motherboard.ToString())
            {
                component = new Motherboard(id, manufacturer,
                                            model, price, overallPerformance, generation);
            }
            if (componentType
                == ComponentType.PowerSupply.ToString())
            {
                component = new PowerSupply(id, manufacturer,
                                            model, price, overallPerformance, generation);
            }
            if (componentType
                == ComponentType.RandomAccessMemory.ToString())
            {
                component = new RandomAccessMemory(id, manufacturer,
                                                   model, price, overallPerformance, generation);
            }
            if (componentType
                == ComponentType.SolidStateDrive.ToString())
            {
                component = new SolidStateDrive(id, manufacturer,
                                                model, price, overallPerformance, generation);
            }
            if (componentType
                == ComponentType.VideoCard.ToString())
            {
                component = new VideoCard(id, manufacturer,
                                          model, price, overallPerformance, generation);
            }

            return(component);
        }
Example #9
0
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            var computer = this.computers.FirstOrDefault(x => x.Id == computerId);

            if (computer == null)
            {
                throw new ArgumentException("Computer with this id does not exist.");
            }

            Models.Products.Components.IComponent component = null;

            switch (componentType)
            {
            case nameof(CentralProcessingUnit):
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case nameof(Motherboard):
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case nameof(PowerSupply):
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case nameof(RandomAccessMemory):
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case nameof(SolidStateDrive):
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case nameof(VideoCard):
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
                break;
            }

            if (component == null)
            {
                throw new ArgumentException("Component type is invalid.");
            }

            if (this.components.Any(x => x.Id == component.Id))
            {
                throw new ArgumentException("Component with this id already exists.");
            }

            computer.AddComponent(component);
            this.components.Add(component);

            return($"Component {component.GetType().Name} with id {component.Id} added successfully in computer with id {computer.Id}.");
        }
Example #10
0
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            var type = new ComponentType();

            var computer = computers.FirstOrDefault(c => c.Id == computerId);

            if (computer == null)
            {
                throw new ArgumentException(ExceptionMessages.NotExistingComputerId);
            }

            if (components.Select(c => c.Id).Contains(id))
            {
                throw new ArgumentException(ExceptionMessages.ExistingComponentId);
            }

            IComponent component = null;

            if (!Enum.TryParse(componentType, out type))
            {
                throw new ArgumentException(ExceptionMessages.InvalidComponentType);
            }
            else if (type == ComponentType.CentralProcessingUnit)
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (type == ComponentType.Motherboard)
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (type == ComponentType.PowerSupply)
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (type == ComponentType.RandomAccessMemory)
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (type == ComponentType.SolidStateDrive)
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (type == ComponentType.VideoCard)
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
            }

            components.Add(component);
            computer.AddComponent(component);

            return(string.Format(SuccessMessages.AddedComponent, componentType, id, computerId));
        }
Example #11
0
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price,
                                   double overallPerformance, int generation)
        {
            IComputer computer = this.computers.FirstOrDefault(c => c.Id == computerId);

            if (computer == null)
            {
                throw new ArgumentException("Computer with this id does not exist.");
            }


            IComponent component = this.components.FirstOrDefault(c => c.Id == id);

            if (component != null)
            {
                throw new ArgumentException("Component with this id already exists.");
            }

            if (componentType == Common.Enums.ComponentType.CentralProcessingUnit.ToString())
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == Common.Enums.ComponentType.Motherboard.ToString())
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == Common.Enums.ComponentType.PowerSupply.ToString())
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == Common.Enums.ComponentType.RandomAccessMemory.ToString())
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == Common.Enums.ComponentType.SolidStateDrive.ToString())
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == Common.Enums.ComponentType.VideoCard.ToString())
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
            }
            else
            {
                throw new ArgumentException("Component type is invalid.");
            }

            this.components.Add(component);
            computer.AddComponent(component);

            return($"Component {componentType} with id {id} added successfully in computer with id {computerId}.");
        }
Example #12
0
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            IComputer currComp = computers.FirstOrDefault(c => c.Id == computerId);

            if (!computers.Contains(currComp))
            {
                throw new ArgumentException(string.Format(Common.Constants.ExceptionMessages.NotExistingComputerId));
            }

            var currComponent = components.FirstOrDefault(c => c.Id == id);

            if (currComponent != null)
            {
                throw new ArgumentException(string.Format(Common.Constants.ExceptionMessages.ExistingComponentId));
            }

            IComponent component = null;

            if (componentType == nameof(CentralProcessingUnit))
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == nameof(Motherboard))
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == nameof(PowerSupply))
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == nameof(RandomAccessMemory))
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == nameof(SolidStateDrive))
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (componentType == nameof(VideoCard))
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
            }
            else
            {
                throw new ArgumentException(string.Format(Common.Constants.ExceptionMessages.InvalidComponentType));
            }

            currComp.AddComponent(component);
            components.Add(component);
            return(string.Format(Common.Constants.SuccessMessages.AddedComponent, componentType, id, computerId));
        }
Example #13
0
        public string AddComponent(int computerId, int id, string componentType,
                                   string manufacturer, string model, decimal price,
                                   double overallPerformance, int generation)
        {
            ComponentType cType     = new ComponentType();
            IComponent    component = null;

            if (DoesComputerExist(computerId))
            {
                throw new ArgumentException(COMPUTER_DOESNT_EXIST);
            }
            else if (computers.Where(x => x.Id == computerId).Any(x => x.Components.Any(x => x.Id == id)))
            {
                throw new ArgumentException("Component with this id already exists.");
            }
            else if (!Enum.TryParse <ComponentType>(componentType, out cType))
            {
                throw new ArgumentException("Component type is invalid.");
            }
            else if (cType == ComponentType.CentralProcessingUnit)
            {
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (cType == ComponentType.Motherboard)
            {
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (cType == ComponentType.PowerSupply)
            {
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (cType == ComponentType.RandomAccessMemory)
            {
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (cType == ComponentType.SolidStateDrive)
            {
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
            }
            else if (cType == ComponentType.VideoCard)
            {
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
            }

            components.Add(component);
            IComputer computer = computers.Where(x => x.Id == computerId).FirstOrDefault();

            computer.AddComponent(component);
            return($"Component {component.GetType().Name} with id {component.Id} added successfully in computer with id {computer.Id}.");
        }
Example #14
0
        public string AddComponent(int computerId, int id, string componentTypeName, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            var currentComputer = this.computers.FirstOrDefault(x => x.Id == computerId);

            NonExistingComputeId(currentComputer);

            if (!Enum.TryParse(componentTypeName, out ComponentType componentType))
            {
                throw new ArgumentException(ExceptionMessages.InvalidComponentType);
            }
            if (this.components.Any(x => x.Id == id))
            {
                throw new ArgumentException(ExceptionMessages.ExistingComponentId);
            }

            IComponent component = null;

            switch (componentType)
            {
            case ComponentType.CentralProcessingUnit:
                component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case ComponentType.Motherboard:
                component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case ComponentType.PowerSupply:
                component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case ComponentType.RandomAccessMemory:
                component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case ComponentType.SolidStateDrive:
                component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
                break;

            case ComponentType.VideoCard:
                component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
                break;
            }


            currentComputer.AddComponent(component);
            components.Add(component);

            return(string.Format(SuccessMessages.AddedComponent, componentTypeName, id, computerId));
        }
        public override PersonalComputer MakePersonalComputer()
        {
            var ram = new RandomAcessMemory(PersonalComputerRam);
            var videoCard = new VideoCard(PersonalComputerMonochromeVideoCard);
            var motherBoard = new Motherboard(ram, videoCard);
            var cpu = new CentralProcessingUnit(PersonalComputerNumberOfCores, PersonalComputerBits, motherBoard);
            var hardDrive = new HardDriver(PersonalComputerHardDriveCapacity, false, 0);

            var dellPersonalComputer = new PersonalComputer(
                cpu,
                ram,
                new List<HardDriver> { hardDrive },
                videoCard,
                motherBoard);
            return dellPersonalComputer;
        }
        public override Server MakeServer()
        {
            // TODO:make raid
            var ram = new RandomAcessMemory(ServerRam);
            var videoCard = new VideoCard(ServerMonochromeVideoCard);
            var motherBoard = new Motherboard(ram, videoCard);
            var cpu = new CentralProcessingUnit(ServerNumberOfCores, ServerBits, motherBoard);
            var hardDrive = new HardDriver(ServerHardDriveCapacity, false, 0);

            var dellServer = new Server(
                cpu,
                ram,
                new List<HardDriver> { hardDrive },
                videoCard,
                motherBoard);
            return dellServer;
        }
        public override Laptop MakeLaptop()
        {
            var ram = new RandomAcessMemory(LaptopRam);
            var videoCard = new VideoCard(LaptopMonochromeVideoCard);
            var motherBoard = new Motherboard(ram, videoCard);
            var cpu = new CentralProcessingUnit(LaptopNumberOfCores, LaptopBits, motherBoard);
            var hardDrive = new HardDriver(LaptopHardDriveCapacity, false, 0);
            var battery = new LaptopBattery();

            var dellLaptop = new Laptop(
                cpu,
                ram,
                new List<HardDriver> { hardDrive },
                videoCard,
                motherBoard,
                battery);
            return dellLaptop;
        }
Example #18
0
        public override PersonalComputer MakePersonalComputer()
        {
            var ram         = new RandomAcessMemory(PersonalComputerRam);
            var videoCard   = new VideoCard(PersonalComputerMonochromeVideoCard);
            var motherBoard = new Motherboard(ram, videoCard);
            var cpu         = new CentralProcessingUnit(PersonalComputerNumberOfCores, PersonalComputerBits, motherBoard);
            var hardDrive   = new HardDriver(PersonalComputerHardDriveCapacity, false, 0);

            var dellPersonalComputer = new PersonalComputer(
                cpu,
                ram,
                new List <HardDriver> {
                hardDrive
            },
                videoCard,
                motherBoard);

            return(dellPersonalComputer);
        }
Example #19
0
        public string AddComponent(int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            CheckThatComputerWithThisIdExist(computerId);

            var findComputer = this.computers.FirstOrDefault(c => c.Id == computerId);

            if (this.components.Any(c => c.Id == id))
            {
                throw new ArgumentException($"Component with this id already exists.");
            }

            IComponent component = null;

            switch (componentType)
            {
                case "CentralProcessingUnit":
                    component = new CentralProcessingUnit(id, manufacturer, model, price, overallPerformance, generation);
                    break;
                case "Motherboard":
                    component = new Motherboard(id, manufacturer, model, price, overallPerformance, generation);
                    break;
                case "PowerSupply":
                    component = new PowerSupply(id, manufacturer, model, price, overallPerformance, generation);
                    break;
                case "RandomAccessMemory":
                    component = new RandomAccessMemory(id, manufacturer, model, price, overallPerformance, generation);
                    break;
                case "SolidStateDrive":
                    component = new SolidStateDrive(id, manufacturer, model, price, overallPerformance, generation);
                    break;
                case "VideoCard":
                    component = new VideoCard(id, manufacturer, model, price, overallPerformance, generation);
                    break;
                default:
                    throw new ArgumentException($"Component type is invalid.");
            }

            this.components.Add(component);
            findComputer.AddComponent(component);

            return $"Component {componentType} with id {id} added successfully in computer with id {computerId}.";
        }
Example #20
0
        public override Server MakeServer()
        {
            // TODO:make raid
            var ram         = new RandomAcessMemory(ServerRam);
            var videoCard   = new VideoCard(ServerMonochromeVideoCard);
            var motherBoard = new Motherboard(ram, videoCard);
            var cpu         = new CentralProcessingUnit(ServerNumberOfCores, ServerBits, motherBoard);
            var hardDrive   = new HardDriver(ServerHardDriveCapacity, false, 0);

            var dellServer = new Server(
                cpu,
                ram,
                new List <HardDriver> {
                hardDrive
            },
                videoCard,
                motherBoard);

            return(dellServer);
        }
Example #21
0
        public override Laptop MakeLaptop()
        {
            var ram         = new RandomAcessMemory(LaptopRam);
            var videoCard   = new VideoCard(LaptopMonochromeVideoCard);
            var motherBoard = new Motherboard(ram, videoCard);
            var cpu         = new CentralProcessingUnit(LaptopNumberOfCores, LaptopBits, motherBoard);
            var hardDrive   = new HardDriver(LaptopHardDriveCapacity, false, 0);
            var battery     = new LaptopBattery();

            var dellLaptop = new Laptop(
                cpu,
                ram,
                new List <HardDriver> {
                hardDrive
            },
                videoCard,
                motherBoard,
                battery);

            return(dellLaptop);
        }
Example #22
0
        public string AddComponent
            (int computerId, int id, string componentType, string manufacturer, string model, decimal price, double overallPerformance, int generation)
        {
            if (computers.Any(c => c.Id == id))
            {
                bool IsValidType = Enum.TryParse <ComponentType>(componentType, out ComponentType componType);
                if (IsValidType)
                {
                    Component component = null;
                    string    message   = string.Empty;

                    switch (componType)
                    {
                    case ComponentType.CentralProcessingUnit:
                        component = new CentralProcessingUnit(overallPerformance, price, model, manufacturer, id, generation);
                        if (components.Any(c => c.Id == id))
                        {
                            throw new ArgumentException(ExceptionMessages.ExistingComponentId);
                        }
                        else
                        {
                            components.Add(component);
                            message = string.Format(SuccessMessages.AddedComponent, id);
                        }
                        break;

                    case ComponentType.Motherboard:
                        component = new Motherboard(overallPerformance, price, model, manufacturer, id, generation);
                        if (components.Any(c => c.Id == id))
                        {
                            throw new ArgumentException(ExceptionMessages.ExistingComponentId);
                        }
                        else
                        {
                            components.Add(component);
                            message = string.Format(SuccessMessages.AddedComponent, id);
                        }
                        break;

                    case ComponentType.PowerSupply:
                        component = new PowerSupply(overallPerformance, price, model, manufacturer, id, generation);
                        if (components.Any(c => c.Id == id))
                        {
                            throw new ArgumentException(ExceptionMessages.ExistingComponentId);
                        }
                        else
                        {
                            components.Add(component);
                            message = string.Format(SuccessMessages.AddedComponent, id);
                        }
                        break;

                    case ComponentType.RandomAccessMemory:
                        component = new RandomAccessMemory(overallPerformance, price, model, manufacturer, id, generation);
                        if (components.Any(c => c.Id == id))
                        {
                            throw new ArgumentException(ExceptionMessages.ExistingComponentId);
                        }
                        else
                        {
                            components.Add(component);
                            message = string.Format(SuccessMessages.AddedComponent, id);
                        }
                        break;

                    case ComponentType.SolidStateDrive:
                        component = new SolidStateDrive(overallPerformance, price, model, manufacturer, id, generation);
                        if (components.Any(c => c.Id == id))
                        {
                            throw new ArgumentException(ExceptionMessages.ExistingComponentId);
                        }
                        else
                        {
                            components.Add(component);
                            message = string.Format(SuccessMessages.AddedComponent, id);
                        }
                        break;

                    case ComponentType.VideoCard:
                        component = new VideoCard(overallPerformance, price, model, manufacturer, id, generation);
                        if (components.Any(c => c.Id == id))
                        {
                            throw new ArgumentException(ExceptionMessages.ExistingComponentId);
                        }
                        else
                        {
                            components.Add(component);
                            message = string.Format(SuccessMessages.AddedComponent, id);
                        }
                        break;

                    default:
                        break;
                    }

                    return(message);
                }
                else
                {
                    throw new ArgumentException(ExceptionMessages.InvalidComponentType);
                }
            }
            else
            {
                throw new ArgumentException(ExceptionMessages.NotExistingComputerId);
            }
        }
Example #23
0
 public PersonalComputer(CentralProcessingUnit cpu, RandomAcessMemory ram, IEnumerable <HardDriver> hardDrives, IVideoCard videoCard, IMotherboard motherBoard)
     : base(cpu, ram, hardDrives, videoCard, motherBoard)
 {
 }
Example #24
0
 public Server(CentralProcessingUnit cpu, RandomAcessMemory ram, IEnumerable <HardDriver> hardDrives, IVideoCard videoCard, IMotherboard motherBoard)
     : base(cpu, ram, hardDrives, videoCard, motherBoard)
 {
     this.CheckIfVideoCardIsMonochrome();
 }
Example #25
0
 public void TestInitialize()
 {
     this.cpu = new CentralProcessingUnit(2, 32, new Motherboard(new RandomAcessMemory(2), new VideoCard(false)));
 }
Example #26
0
 public Laptop(CentralProcessingUnit cpu, RandomAcessMemory ram, IEnumerable<HardDriver> hardDrives, IVideoCard videoCard, IMotherboard motherBoard, LaptopBattery battery)
     : base(cpu, ram, hardDrives, videoCard, motherBoard)
 {
     this.LaptopBattery = battery;
 }
Example #27
0
 public Server(CentralProcessingUnit cpu, RandomAcessMemory ram, IEnumerable<HardDriver> hardDrives, IVideoCard videoCard, IMotherboard motherBoard)
     : base(cpu, ram, hardDrives, videoCard, motherBoard)
 {
     this.CheckIfVideoCardIsMonochrome();
 }
 public void TestInitialize()
 {
     this.cpu = new CentralProcessingUnit(2, 32, new Motherboard(new RandomAcessMemory(2), new VideoCard(false)));
 }
Example #29
0
 public Laptop(CentralProcessingUnit cpu, RandomAcessMemory ram, IEnumerable <HardDriver> hardDrives, IVideoCard videoCard, IMotherboard motherBoard, LaptopBattery battery)
     : base(cpu, ram, hardDrives, videoCard, motherBoard)
 {
     this.LaptopBattery = battery;
 }
 public PersonalComputer(CentralProcessingUnit cpu, RandomAcessMemory ram, IEnumerable<HardDriver> hardDrives, IVideoCard videoCard, IMotherboard motherBoard)
     : base(cpu, ram, hardDrives, videoCard, motherBoard)
 {
 }