コード例 #1
0
        private static void CheckTheManufacturer(string manufacturer, ref PersonalComputer pc, ref Laptop laptop, ref Server server)
        {
            if (manufacturer == "HP")
            {
                var hpManufacturer = new HPManufacturer();
                var factoryManager = new FactoryManager(hpManufacturer);

                pc = factoryManager.MakePersonalComputer();
                laptop = factoryManager.MakeLaptop();
                server = factoryManager.MakeServer();
            }
            else if (manufacturer == "Dell")
            {
                var dellManufacturer = new DellManufacturer();
                var factoryManager = new FactoryManager(dellManufacturer);

                pc = factoryManager.MakePersonalComputer();
                laptop = factoryManager.MakeLaptop();
                server = factoryManager.MakeServer();
            }
            else if (manufacturer == "Lenovo")
            {
                var lenovoManufacturer = new LenovoManufacturer();
                var factoryManager = new FactoryManager(lenovoManufacturer);

                pc = factoryManager.MakePersonalComputer();
                laptop = factoryManager.MakeLaptop();
                server = factoryManager.MakeServer();
            }
            else
            {
                throw new ArgumentException("Invalid manufacturer!");
            }
        }
コード例 #2
0
        private static void ExecuteCommand(PersonalComputer pc, Laptop laptop, Server server, string[] commandParameters)
        {
            var inputConsoleCommand = commandParameters[0];
            var commandArgument = int.Parse(commandParameters[1]);

            if (inputConsoleCommand == "Charge")
            {
                string result = laptop.ChargeBattery(commandArgument);
                laptop.VideoCardOfComputer.Draw(result + "%");
            }
            else if (inputConsoleCommand == "Process")
            {
                string result = server.Process(commandArgument);
                server.VideoCardOfComputer.Draw(result);
            }
            else if (inputConsoleCommand == "Play")
            {
                string result = pc.Play(commandArgument);
                pc.VideoCardOfComputer.Draw(result);
            }
            else
            {
                Console.WriteLine("Invalid command!");
            }
        }
コード例 #3
0
        public override Laptop MakeLaptop()
        {
            CPU cpu = new CPU(2, 64);
            RAM ram = new RAM(16);
            HardDrive hardDrive = new HardDrive(1000, false, 0);
            VideoCard videoCard = new VideoCard(false);
            Battery battery = new Battery();

            Laptop lenovoLaptop = new Laptop(cpu, ram, hardDrive, videoCard, battery);

            return lenovoLaptop;
        }
コード例 #4
0
        public override Laptop MakeLaptop()
        {
            CPU cpu = new CPU(4, 32);
            RAM ram = new RAM(8);
            HardDrive hardDrive = new HardDrive(1000, false, 0);
            VideoCard videoCard = new VideoCard(false);
            Battery battery = new Battery();

            Laptop dellLaptop = new Laptop(cpu, ram, hardDrive, videoCard, battery);

            return dellLaptop;
        }