Пример #1
0
 public CPU(byte numberOfCores, CPUTypes numberOfBits, RAM ram, VideoCard videoCard)
 {
     this.NumberOfCores = numberOfCores;
     this.numberOfBits = numberOfBits;
     this.ram = ram;
     this.videoCard = videoCard;
 }
Пример #2
0
 public Computer(Cpu cpu, RAM ram, IEnumerable<HardDrive> hardDrives)
 {
     this.Cpu = cpu;
     this.Ram = ram;
     this.HardDrives = hardDrives;
     this.VideoCard = new VideoCard();
     this.Motherboard = new Motherboard(this.Ram, this.VideoCard);
 }
        public void CPUSquareNumber64bitTests()
        {
            RAM laptopRAM = new RAM(4);
            var laptopVideoCard = new VideoCard(false);
            var laptopCPU = new CPU(2, CPUTypes._64bit, laptopRAM, laptopVideoCard);

            laptopCPU.SquareNumber();
        }
Пример #4
0
 public override Server CreateServer()
 {
     var serverRam = new RAM(32);
     var cpu = new Cpu32Bit(4);
     var hardDrivesList = new List<HardDrive> { new HardDrive(0, true, 2, new List<HardDrive> { new HardDrive(1000, false, 0), new HardDrive(1000, false, 0) }) };
     var server = new Server(cpu, serverRam, hardDrivesList);
     return server;
 }
Пример #5
0
 public override Server CreateServer()
 {
     var ram = new RAM(64);
     var cpu = new Cpu64Bit(8);
     var hardDrivesList = new List<HardDrive> { new HardDrive(0, true, 2, new List<HardDrive> { new HardDrive(2000, false, 0), new HardDrive(2000, false, 0) }) };
     var server = new Server(cpu, ram, hardDrivesList);
     return server;
 }
Пример #6
0
 public override PC CreatePC()
 {
     var ram = new RAM(8);
     var cpu = new Cpu64Bit(4);
     HardDrive[] hardDrive = new[] { new HardDrive(1000, false, 0) };
     var pc = new PC(cpu, ram, hardDrive);
     return pc;
 }
Пример #7
0
 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;
 }
Пример #8
0
        public override PC CreatePC()
        {
            var ram = new RAM(2);
            var cpu = new Cpu32Bit(2);
            HardDrive[] hardDrive = new[] { new HardDrive(500, false, 0) };
            PC pc = new PC(cpu, ram, hardDrive);

            return pc;
        }
Пример #9
0
 public void GenerateRandomInteger(int minValue, int maxValue, RAM ram)
 {
     int randomNumber;
     do
     {
         randomNumber = Random.Next(0, 1000);
     }
     while (!(randomNumber >= minValue && randomNumber <= maxValue));
     ram.SaveRamValue(randomNumber);
 }
Пример #10
0
        public override PC CreatePC()
        {
            var ram = new RAM(4);
            var cpu = new Cpu64Bit(2);
            HardDrive[] hardDrive = new[] { new HardDrive(2000, false, 0) };
            PC pc = new PC(cpu, ram, hardDrive);
            pc.VideoCard.IsMonochrome = true;

            return pc;
        }
        public void OverChargeBatteryTest()
        {
            RAM laptopRAM = new RAM(4);
            var laptopVideoCard = new VideoCard(false);
            var laptopHardDrives = new[] { new HardDrive(500, false, 0) };
            var laptopBattery = new LaptopBattery();
            var laptopCPU = new CPU(2, CPUTypes._64bit, laptopRAM, laptopVideoCard);

            Computer laptop = new Computer(ComputerType.LAPTOP, laptopCPU, laptopRAM, laptopHardDrives, laptopVideoCard, laptopBattery);
            laptop.ChargeBattery(300);
        }
Пример #12
0
        public Computer(ComputerType type, CPU cpu, RAM ram, IEnumerable<HardDrive> hardDrives, VideoCard videoCard, LaptopBattery battery)
        {
            this.CPU = cpu;
            this.RAM = ram;
            this.HardDrives = hardDrives;
            this.VideoCard = videoCard;
            if (type != ComputerType.LAPTOP && type != ComputerType.PC)
            {
                this.VideoCard.IsMonochrome = true;
            }

            this.battery = battery;
        }
Пример #13
0
        public void ScquareNumber(RAM ram, VideoCard videoCard)
        {
            var storedData = ram.LoadRamValue();
            if (storedData < 0)
            {
                videoCard.DrawOnVideoCard("Number too low.");
            }
            else if ((storedData > 500 && this.NumberOfBits == 32)
                    || (storedData > 1000 && this.NumberOfBits == 64)
                    || (storedData > 2000 && this.NumberOfBits == 128))
            {
                videoCard.DrawOnVideoCard("Number too high.");
            }
            else
            {
                int value = 0;
                for (int i = 0; i < storedData; i++)
                {
                    value += storedData;
                }

                videoCard.DrawOnVideoCard(string.Format("Square of {0} is {1}.", storedData, value));
            }
        }
Пример #14
0
 public Motherboard(RAM ram, VideoCard videoCard)
 {
     this.ram = ram;
     this.videoCard = videoCard;
 }
Пример #15
0
 public PC(Cpu cpu, RAM ram, IEnumerable<HardDrive> hardDrives)
     : base(cpu, ram, hardDrives)
 {
     this.VideoCard.IsMonochrome = false;
 }
Пример #16
0
 public Laptop(Cpu cpu, RAM ram, IEnumerable<HardDrive> hardDrives, LaptopBattery battery)
     : base(cpu, ram, hardDrives)
 {
     this.Battery = battery;
     this.VideoCard.IsMonochrome = false;
 }
        public static void Main()
        {
            var manufacturer = Console.ReadLine();
            if (manufacturer == "HP")
            {
                var personalComputerRAM = new RAM(2);
                var personalComputerVideoCard = new VideoCard(false);
                var personalComputerHardDrives = new[] { new HardDrive(500, false, 0) };
                var personalComputerCPU = new CPU(2, CPUTypes._32bit, personalComputerRAM, personalComputerVideoCard);

                personalComputer = new Computer(ComputerType.PC, personalComputerCPU, personalComputerRAM, personalComputerHardDrives, personalComputerVideoCard, null);

                var serverRAM = new RAM(32);
                var serverVideoCard = new VideoCard();
                var serverHardDrives = new List<HardDrive> { new HardDrive(0, true, 2, new List<HardDrive> { new HardDrive(1000, false, 0), new HardDrive(1000, false, 0) }) };
                var serverCPU = new CPU(4, CPUTypes._32bit, serverRAM, serverVideoCard);

                server = new Computer(ComputerType.SERVER, serverCPU, serverRAM, serverHardDrives, serverVideoCard, null);

                var laptopRAM = new RAM(4);
                var laptopVideoCard = new VideoCard(false);
                var laptopHardDrives = new[] { new HardDrive(500, false, 0) };
                var laptopBattery = new LaptopBattery();
                var laptopCPU = new CPU(2, CPUTypes._64bit, laptopRAM, laptopVideoCard);

                laptop = new Computer(ComputerType.LAPTOP, laptopCPU, laptopRAM, laptopHardDrives, laptopVideoCard, laptopBattery);
            }
            else if (manufacturer == "Dell")
            {
                var personalComputerRAM = new RAM(8);
                var personalComputerVideoCard = new VideoCard(false);
                var personalComputerHardDrives = new[] { new HardDrive(1000, false, 0) };
                var personalComputerCPU = new CPU(4, CPUTypes._64bit, personalComputerRAM, personalComputerVideoCard);

                personalComputer = new Computer(ComputerType.PC, personalComputerCPU, personalComputerRAM, personalComputerHardDrives, personalComputerVideoCard, null);

                var serverRAM = new RAM(64);
                var serverVideoCard = new VideoCard();
                var serverHardDrives = new List<HardDrive> { new HardDrive(0, true, 2, new List<HardDrive> { new HardDrive(2000, false, 0), new HardDrive(2000, false, 0) }) };
                var serverCPU = new CPU(8, CPUTypes._64bit, serverRAM, serverVideoCard);

                server = new Computer(ComputerType.SERVER, serverCPU, serverRAM, serverHardDrives, serverVideoCard, null);

                var laptopRAM = new RAM(8);
                var laptopVideoCard = new VideoCard(false);
                var laptopHardDrives = new[] { new HardDrive(1000, false, 0) };
                var laptopBattery = new LaptopBattery();
                var laptopCPU = new CPU(4, CPUTypes._32bit, laptopRAM, laptopVideoCard);

                laptop = new Computer(ComputerType.LAPTOP, laptopCPU, laptopRAM, laptopHardDrives, laptopVideoCard, laptopBattery);
            }
            else if (manufacturer == "Lenovo")
            {
                var personalComputerRAM = new RAM(4);
                var personalComputerVideoCard = new VideoCard(true);
                var personalComputerHardDrives = new[] { new HardDrive(2000, false, 0) };
                var personalComputerCPU = new CPU(2, CPUTypes._64bit, personalComputerRAM, personalComputerVideoCard);

                personalComputer = new Computer(ComputerType.PC, personalComputerCPU, personalComputerRAM, personalComputerHardDrives, personalComputerVideoCard, null);

                var serverRAM = new RAM(8);
                var serverVideoCard = new VideoCard();
                var serverHardDrives = new List<HardDrive> { new HardDrive(0, true, 2, new List<HardDrive> { new HardDrive(500, false, 0), new HardDrive(500, false, 0) }) };
                var serverCPU = new CPU(2, CPUTypes._128bit, serverRAM, serverVideoCard);

                server = new Computer(ComputerType.SERVER, serverCPU, serverRAM, serverHardDrives, serverVideoCard, null);

                var laptopRAM = new RAM(16);
                var laptopVideoCard = new VideoCard(false);
                var laptopHardDrives = new[] { new HardDrive(1000, false, 0) };
                var laptopBattery = new LaptopBattery();
                var laptopCPU = new CPU(2, CPUTypes._64bit, laptopRAM, laptopVideoCard);

                laptop = new Computer(ComputerType.LAPTOP, laptopCPU, laptopRAM, laptopHardDrives, laptopVideoCard, laptopBattery);
            }
            else
            {
                throw new InvalidArgumentException("Invalid manufacturer!");
            }

            var command = Console.ReadLine();

            while (command != null && command != "Exit")
            {
                var commandArguments = command.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (commandArguments.Length != 2)
                {
                    throw new ArgumentException("Invalid command!");
                }

                var commandName = commandArguments[0];
                var commandParameter = int.Parse(commandArguments[1]);
                if (commandName == "Charge")
                {
                    laptop.ChargeBattery(commandParameter);
                }
                else if (commandName == "Process")
                {
                    server.Process(commandParameter);
                }
                else if (commandName == "Play")
                {
                    personalComputer.Play(commandParameter);
                }

                command = Console.ReadLine();
            }
        }
Пример #18
0
 public Server(Cpu cpu, RAM ram, IEnumerable<HardDrive> hardDrives)
     : base(cpu, ram, hardDrives)
 {
     this.VideoCard.IsMonochrome = true;
 }