예제 #1
0
    private static void RegisterHeavyHardwareCommand(string[] inputArgs, List <Hardware> hardware)
    {
        var hhName     = inputArgs[1];
        var hhCapacity = int.Parse(inputArgs[2]);
        var hhMemory   = int.Parse(inputArgs[3]);

        var heavyHardware = new HeavyHardware(hhName, hhCapacity, hhMemory);

        hardware.Add(heavyHardware);
    }
예제 #2
0
        private static void RegisterHeavyHardware(string info)
        {
            string[] componentInfo = info.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
            string   name          = componentInfo[0];
            int      capacity      = int.Parse(componentInfo[1]);
            int      memory        = int.Parse(componentInfo[2]);

            var heavyHardware = new HeavyHardware(name, capacity, memory);

            TheSystem.Components.Add(heavyHardware);
        }
예제 #3
0
        private static void CreateHeavyHardware(Match match, List <Hardware> components)
        {
            string[] tokens =
                match.Groups[2].Value.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
            string name         = tokens[0];
            int    capacity     = int.Parse(tokens[1]);
            int    memory       = int.Parse(tokens[2]);
            var    newComponent = new HeavyHardware(name, capacity, memory);

            components.Add(newComponent);
        }
예제 #4
0
        private static string CreateHeavyHardware(string[] dataSystem, string name, out Hardware hardwaredHeavy)
        {
            string nameHHardware     = dataSystem[0];
            int    capacityHHardware = int.Parse(dataSystem[1]);
            int    memoryHHardware   = int.Parse(dataSystem[2]);

            hardwaredHeavy = new HeavyHardware(name,
                                               capacityHHardware, memoryHHardware, new List <Software>());

            return(nameHHardware);
        }
예제 #5
0
        public void CheckingValueExtractionFromGivenCommandString()
        {
            //Arrange
            List <Hardware> system           = new List <Hardware>();
            string          inputCommand     = "RegisterHeavyHardware(SSD, 400, 400)";
            var             expectedhardware = new HeavyHardware("SSD", 400, 400);

            //Act
            var commandManager = new CommandManager();

            commandManager.RegisterHeavyHardware(system, inputCommand);

            //Assert
            Assert.AreEqual(system[0].Name, expectedhardware.Name);
            Assert.AreEqual(system[0].MaximumCapacity, expectedhardware.MaximumCapacity);
            Assert.AreEqual(system[0].MaximumMemory, expectedhardware.MaximumMemory);
        }
예제 #6
0
        public IComponentHardware CreateHardware(string type,
                                                 string name, int capacity, int memory)
        {
            IComponentHardware componentHardware = null;

            switch (type)
            {
            case "PowerHardware":
                return(componentHardware = new PowerHardware(name, capacity, memory, type));

                break;

            case "HeavyHardware":
                return(componentHardware = new HeavyHardware(name, capacity, memory, type));

                break;
            }

            return(componentHardware);
        }
예제 #7
0
        static void Main(string[] args)
        {
            string pattern   = @"(\w+)(\((.*?)\))?";
            string inputLine = Console.ReadLine();
            Regex  regex     = new Regex(pattern);

            while (inputLine != "System Split")
            {
                Match matcher = regex.Match(inputLine);

                if (matcher.Groups[1].Value == "RegisterPowerHardware")
                {
                    string hardwareType = "Power";

                    string[] hardwareData = matcher.Groups[3].Value.Split(',');

                    string hardwareName = hardwareData[0].Trim();

                    int hardwareCapacity = int.Parse(hardwareData[1].Trim());

                    int hardwareMemory = int.Parse(hardwareData[2].Trim());

                    Hardware hardware = new PowerHardware(hardwareName, hardwareType, hardwareCapacity, hardwareMemory);
                    MySystem.RegisterHardware(hardware);
                }

                else if (matcher.Groups[1].Value == "RegisterHeavyHardware")
                {
                    string hardwareType = "Heavy";

                    string[] hardwareData = matcher.Groups[3].Value.Split(',');

                    string hardwareName = hardwareData[0].Trim();

                    int hardwareCapacity = int.Parse(hardwareData[1].Trim());

                    int hardwareMemory = int.Parse(hardwareData[2].Trim());

                    Hardware hardware = new HeavyHardware(hardwareName, hardwareType, hardwareCapacity, hardwareMemory);
                    MySystem.RegisterHardware(hardware);
                }

                else if (matcher.Groups[1].Value == "RegisterExpressSoftware")
                {
                    string softwareType = "ExpressSoftware";

                    string[] softwareData = matcher.Groups[3].Value.Split(',');

                    string hardwareComponentName = softwareData[0].Trim();

                    string softwareName = softwareData[1].Trim();

                    int softwareCapacityConsumption = int.Parse(softwareData[2].Trim());

                    int softwareMemoryconsumption = int.Parse(softwareData[3].Trim());

                    Software software = new ExpressSoftware(softwareName, softwareType, softwareCapacityConsumption, softwareMemoryconsumption);
                    MySystem.RegisterSoftware(hardwareComponentName, software);
                }

                else if (matcher.Groups[1].Value == "RegisterLightSoftware")
                {
                    string softwareType = "LightSoftware";

                    string[] softwareData = matcher.Groups[3].Value.Split(',');

                    string hardwareComponentName = softwareData[0].Trim();

                    string softwareName = softwareData[1].Trim();

                    int softwareCapacityConsumption = int.Parse(softwareData[2].Trim());

                    int softwareMemoryconsumption = int.Parse(softwareData[3].Trim());

                    Software software = new LightSoftware(softwareName, softwareType, softwareCapacityConsumption, softwareMemoryconsumption);
                    MySystem.RegisterSoftware(hardwareComponentName, software);
                }

                else if (matcher.Groups[1].Value == "ReleaseSoftwareComponent")
                {
                    string[] dataForSoftwareRelease = matcher.Groups[3].Value.Split(',');

                    string hardwareComponentName = dataForSoftwareRelease[0].Trim();

                    string softwareComponentName = dataForSoftwareRelease[1].Trim();

                    MySystem.ReleaseSoftowareComponent(hardwareComponentName, softwareComponentName);
                }

                else if (matcher.Groups[1].Value == "Analyze")
                {
                    MySystem.Analyze();
                }

                inputLine = Console.ReadLine();
            }

            MySystem.SystemSplit();
        }
예제 #8
0
        private void RegisterHeavyHardware(string name, int maxCapacity, int maxMemory)
        {
            HeavyHardware heavyHardware = new HeavyHardware(name, maxCapacity, maxMemory);

            this.CustomSystem.AddHardware(heavyHardware);
        }
예제 #9
0
        protected HardwareComponent CreateHeavyHardware(string[] data)
        {
            HardwareComponent heavyHardwareComponent = new HeavyHardware(data[0], int.Parse(data[1]), int.Parse(data[2]));

            return(heavyHardwareComponent);
        }