コード例 #1
0
ファイル: HP.cs プロジェクト: Elinos/TelerikAcademy
 public override Laptop CreateLaptop()
 {
     var ram = new RAM(4);
     var cpu = new Cpu64Bit(2);
     HardDrive[] hardDrive = new[] { new HardDrive(500, false, 0) };
     var laptopBattery = new LaptopBattery();
     var laptop = new Laptop(cpu, ram, hardDrive, laptopBattery);
     return laptop;
 }
コード例 #2
0
 public override Laptop CreateLaptop()
 {
     var ram = new Ram(8);
     var videoCard = new VideoCard { IsMonochrome = false };
     var laptop = new Laptop(
      new Cpu(4, 32, ram, videoCard),
      ram,
      new[] { new HardDrive(1000, false, 0) },
      videoCard,
      new LaptopBatteryReal());
     return laptop;
 }
コード例 #3
0
        public void Start()
        {
            while (true)
            {
                var curentCommand = Console.ReadLine();
                if (curentCommand == null)
                {
                    break;
                }

                if (curentCommand.StartsWith("Exit"))
                {
                    break;
                }

                if (!curentCommand.Contains(" "))
                {
                    if (curentCommand == "HP")
                    {
                        this.pc     = new PC(new Cpu32(2), new Ram(2), new HardDrive(500), new VideoCardColorful());
                        this.server = new Server(new Cpu32(4), new Ram(32), new RaidHardDrive(1000, 2));
                        this.laptop = new Laptop(new Cpu64(2), new Ram(4), new HardDrive(500), new VideoCardColorful(), new LaptopBattery());
                        continue;
                    }
                    else if (curentCommand == "Dell")
                    {
                        this.pc     = new PC(new Cpu64(4), new Ram(8), new HardDrive(1000), new VideoCardColorful());
                        this.server = new Server(new Cpu64(8), new Ram(64), new RaidHardDrive(2000, 2));
                        this.laptop = new Laptop(new Cpu32(4), new Ram(8), new HardDrive(1000), new VideoCardColorful(), new LaptopBattery());
                        continue;
                    }
                    else if (curentCommand == "Lenovo")
                    {
                        this.pc     = new PC(new Cpu64(2), new Ram(4), new HardDrive(20000), new VideoCardMonochrome());
                        this.server = new Server(new Cpu128(2), new Ram(8), new RaidHardDrive(500, 2));
                        this.laptop = new Laptop(new Cpu64(2), new Ram(16), new HardDrive(1000), new VideoCardColorful(), new LaptopBattery());
                        continue;
                    }
                    else
                    {
                        throw new ArgumentException("Invalid manufacturer!");
                    }
                }

                var commandsArray = curentCommand.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (commandsArray.Length != 2)
                {
                    throw new ArgumentException("Invalid command!");
                }

                var commandName     = commandsArray[0];
                var commandArgument = int.Parse(commandsArray[1]);

                if (commandName == "Charge")
                {
                    this.laptop.ChargeBattery(commandArgument);
                }
                else if (commandName == "Process")
                {
                    this.server.Process(commandArgument);
                }
                else if (commandName == "Play")
                {
                    this.pc.Play(commandArgument);
                }
            }
        }
コード例 #4
0
        public IComputer CreateComputer(ICPU cpu, IRam ram, IHardDrive hardDrives, IVideoCard videoCard, IBattery battery)
        {
            IComputer laptop = new Laptop(cpu, ram, hardDrives, videoCard, battery);

            return(laptop);
        }