Пример #1
0
        public string AddComputer(string computerType, int id, string manufacturer, string model, decimal price)
        {
            ComputerType cType    = new ComputerType();
            IComputer    computer = null;

            if (!DoesComputerExist(id))
            {
                throw new ArgumentException("Computer with this id already exists.");
            }
            else if (!Enum.TryParse <ComputerType>(computerType, out cType))
            {
                throw new ArgumentException("Computer type is invalid.");
            }
            else if (cType == ComputerType.DesktopComputer)
            {
                computer = new DesktopComputer(id, manufacturer, model, price);
            }
            else if (cType == ComputerType.Laptop)
            {
                computer = new Laptop(id, manufacturer, model, price);
            }

            computers.Add(computer);
            return($"Computer with id {computer.Id} added successfully.");
        }
Пример #2
0
 public LicenceInfo(int userId, int computerId, int applicationId, ComputerType computerType)
 {
     UserId        = userId;
     ComputerId    = computerId;
     ApplicationId = applicationId;
     ComputerType  = computerType;
 }
Пример #3
0
            internal Computer(ComputerType _type)
            {
                type = _type;
                switch (_type)
                {
                case ComputerType.Desktop:
                    CPUcores     = 4;           //4 Cores
                    CPUFrequency = 2.5;         //2.5 GHz
                    CPUmemory    = 8;           //8 GB RAM
                    CPUHdd       = 500;         //500 GB HDD
                    break;

                case ComputerType.Laptop:
                    CPUcores     = 2;           //2 Cores
                    CPUFrequency = 1.7;         //1.7 GHz
                    CPUmemory    = 4;           //4 GB RAM
                    CPUHdd       = 250;         //500 GB HDD
                    break;

                case ComputerType.Server:
                    CPUcores     = 8;           //8 Cores
                    CPUFrequency = 3.0;         //3 GHz
                    CPUmemory    = 16;          //4 GB RAM
                    CPUHdd       = 2048;        //2 TB HDD
                    break;

                default:
                    CPUcores     = -1;
                    CPUFrequency = -1;
                    CPUmemory    = -1;
                    CPUHdd       = -1;
                    break;
                }
            }
Пример #4
0
        public string AddComputer(string computerType, int id, string manufacturer, string model, decimal price)
        {
            var type = new ComputerType();

            if (this.computers.Select(c => c.Id).Contains(id))
            {
                throw new ArgumentException(ExceptionMessages.ExistingComputerId);
            }

            IComputer computer = null;

            if (!Enum.TryParse(computerType, out type))
            {
                throw new ArgumentException(ExceptionMessages.InvalidComputerType);
            }
            else if (type == ComputerType.Laptop)
            {
                computer = new Laptop(id, manufacturer, model, price);
            }
            else if (type == ComputerType.DesktopComputer)
            {
                computer = new DesktopComputer(id, manufacturer, model, price);
            }

            computers.Add(computer);
            return(string.Format(SuccessMessages.AddedComputer, id));
        }
 public void NewGame(int roundsToWin, ComputerType gameType)
 {
     _playerScore    = 0;
     _computerScore  = 0;
     _roundsToWin    = roundsToWin;
     _computerPlayer = ComputerProvider.GetComputer(gameType);
 }
Пример #6
0
 private void buttonSubmit_Click(object sender, EventArgs e)
 {
     if (procesor == null || video == null)
     {
         MessageBox.Show("You need to set processor and videocard first");
     }
     else
     {
         try
         {
             int          memory      = Helper.GetIntValue(textMemorySize);
             int          driveSize   = Helper.GetIntValue(textDriveSize);
             DateTime     datePurchse = datePurchaseDate.Value;
             ComputerType compType    = GetComputerType();
             RAMType      ramType     = GetRAMType();
             DriveType    driveType   = GetDriveType();
             comp = new Computer(compType, procesor, video, ramType, driveSize, driveType, datePurchse, memory);
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         catch (FormValueError ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Пример #7
0
            public Computer(ComputerType type_)
            {
                PCType = type_;
                switch (type_)
                {
                case ComputerType.Desktop:
                    CPU    = new CPU(4, 2.5);
                    memory = new AmountSize(6, SizeType.GB);
                    HDD    = new AmountSize(500, SizeType.GB);
                    break;

                case ComputerType.Laptop:
                    CPU    = new CPU(2, 1.7);
                    memory = new AmountSize(4, SizeType.GB);
                    HDD    = new AmountSize(250, SizeType.GB);
                    break;

                case ComputerType.Server:
                    CPU    = new CPU(8, 3);
                    memory = new AmountSize(16, SizeType.GB);
                    HDD    = new AmountSize(2, SizeType.TB);
                    break;

                default:
                    CPU    = null;
                    memory = null;
                    HDD    = null;
                    break;
                }
            }
Пример #8
0
    // Start is called before the first frame update
    void Start()
    {
        if (pBar == null)
        {
            pBar = this.gameObject.GetComponentInChildren <LinearProgressBarController> (true);
        }

        computerSpeaker = GetComponent <AudioSource> ();


        CC = GetComponent <CrashController> ();
        CM = FindObjectOfType <ComputerManager> ();

        if (computerID == 0)
        {
            computerID = Random.Range(0, 100);
        }

        // Pick a random computer type
        computerType = (ComputerType)Random.Range(0, System.Enum.GetValues(typeof(ComputerType)).Length);
        _state       = ComputerState.WaitingToCrash;

        // if the timer is greater than 0, we must have set it in the ComputerManager->start, so don't over write it
        if (_crashTimer <= 0)
        {
            _crashTimer = Random.Range(CM.MinDefaultComputerCrashTime, CM.MaxDefaultComputerCrashTime);
        }
    }
Пример #9
0
        public void MassCreateComputerTypes()
        {
            var fakeComputerTypes = new List <ComputerTypeViewModel>();

            for (int i = 1; i < 6; i++)
            {
                var computerType = new ComputerTypeViewModel()
                {
                    ComputerTypeCode        = $"CTCODE{i}",
                    ComputerTypeName        = $"ComputerTypeName {i}",
                    ComputerTypeDescription = $"ComputerTypeDesription {i}",
                    Status = true
                };
                fakeComputerTypes.Add(computerType);
            }

            foreach (var computerTypeViewModel in fakeComputerTypes)
            {
                ComputerType newComputerType = new ComputerType();
                newComputerType.UpdateComputerType(computerTypeViewModel);

                _computerTypeService.Add(newComputerType);
                _computerTypeService.Save();
            }
        }
Пример #10
0
 /// <summary>
 /// Construct a new installation. All data items must be specified.
 /// </summary>
 /// <param name="computerId">The computer ID as an int.</param>
 /// <param name="userId">The user ID as an int.</param>
 /// <param name="applicationId">The application ID as an int.</param>
 /// <param name="computerType">The computer type, drawn from the ComputerType enumeration.</param>
 public Installation(int computerId, int userId, int applicationId, ComputerType computerType)
 {
     ComputerId    = computerId;
     UserId        = userId;
     ApplicationId = applicationId;
     ComputerType  = computerType;
 }
Пример #11
0
 public Computer(ComputerType type, int CPU, float HGz, int Memory, int HDD)
 {
     this.type   = type;
     this.CPU    = CPU;
     this.HGz    = HGz;
     this.Memory = Memory;
     this.HDD    = HDD;
 }
Пример #12
0
 public Computer(ComputerType comType)
 {
     this.comType = comType;
     Core         = 0;
     Frequency    = 0;
     Memory       = 0;
     HDD          = 0;
 }
Пример #13
0
 public ComputerType Add(ComputerType computerType)
 {
     computerType.CreatedDate = DateTime.Now;
     //computerType.CreatedBy = ad //Todo: Add CreatedBy
     computerType.UpdatedDate = DateTime.Now;
     //computerType.UpdatedBy = ad //Todo: Add CreatedBy
     return(_computerTypeRepository.Add(computerType));
 }
Пример #14
0
 public Computer(ComputerType comType)
 {
     this.comType = comType;
     Core = 0;
     Frequency = 0;
     Memory = 0;
     HDD = 0;
 }
Пример #15
0
 public Computer(ComputerType type, ICpu cpu, Ram ram, IEnumerable<HardDrive> hardDrives, IVideoCard videoCard)
 {
     this.Cpu = cpu;
     this.Ram = ram;
     this.HardDrives = hardDrives;
     this.VideoCard = videoCard;
     this.Type = type;
 }
Пример #16
0
 public Computer(ComputerType type, int memmory, float frequency, int cores, int hdd)
 {
     this.type      = type;
     this.memmory   = memmory;
     this.frequency = frequency;
     this.cores     = cores;
     this.hdd       = hdd;
 }
Пример #17
0
 //конструктор
 public Computer(int CPU, int GPU, int HDD, double RAM, ComputerType type)
 {
     this.CPU  = CPU;
     this.GPU  = GPU;
     this.HDD  = HDD;
     this.RAM  = RAM;
     this.type = type;
 }
Пример #18
0
        public string createID(int id)
        {
            ComputerType ct = db.ComputerType.Find(id);

            var    a = db.Computer.Where(c => c.TypeOfComputer == id).Select(c => c.Computer_ID).Max();
            string s = ct.SubUnitID + (ct.ID < 10 ? "0" + ct.ID.ToString() : ct.ID.ToString()) + (a == null ? "0001" : (Convert.ToInt32(a) + 1).ToString().Substring(3, 4));

            return(s);
        }
Пример #19
0
 public Computer(ComputerType type, IMotherboard motherboard, Cpu cpu, Ram ram, IEnumerable<HardDrive> hardDrives, IVideoCard videoCard)
 {
     // TODO: validate
     this.Cpu = cpu;
     this.Ram = ram;
     this.HardDrives = hardDrives;
     this.VideoCard = videoCard;
     this.Motherboard = motherboard;
 }
Пример #20
0
 public ActionResult Edit([Bind(Include = "ID,Title,SubUnitID")] ComputerType computerType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(computerType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(computerType));
 }
Пример #21
0
 // Start is called before the first frame update
 void Start()
 {
     if (computerID == 0)
     {
         computerID = Random.Range(0, 100);
     }
     computerType = (ComputerType)Random.Range(0, System.Enum.GetValues(typeof(ComputerType)).Length);
     _state       = ComputerState.WaitingToCrash;
     _crashTimer  = Random.Range(3f, 20f);
 }
Пример #22
0
        public ActionResult Create([Bind(Include = "ID,Title,SubUnitID")] ComputerType computerType)
        {
            if (ModelState.IsValid)
            {
                db.ComputerType.Add(computerType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(computerType));
        }
        private Installation[] PopulateArray(int count, ComputerType type)
        {
            var outArray = new Installation[count];

            for (var ii = 0; ii < count; ++ii)
            {
                outArray[ii] = new Installation(ii, 0, 0, type);
            }

            return(outArray);
        }
        public static IComputerPlayer GetComputer(ComputerType computerType)
        {
            switch (computerType)
            {
            case ComputerType.RandomComputer:
            default:
                return(new RandomComputerPlayer());

            case ComputerType.TacticalComputer:
                return(new TacticalComputerPlayer());
            }
        }
 public Computer Create(ComputerType type)
 {
     switch (type)
     {
         case ComputerType.Dell:
             return new DellComputer();
         case ComputerType.Hp:
             return new HpComputer();
         default:
             throw new InvalidArgumentException();
     }
 }
Пример #26
0
        public void convert_to_installation__preserves_computer_type()
        {
            const ComputerType computerType = ComputerType.Laptop;

            var installationData = new InstallationData {
                ComputerType = computerType
            };

            var installation = installationData.ToInstallation();

            Assert.That(installation.ComputerType, Is.EqualTo(computerType));
        }
 internal Computer(ComputerType type,
     Cpu cpu,
     RamMemory ram,
     IEnumerable<HardDrive> hardDrives,
     VideoCard videoCard,
     LaptopBattery battery)
 {
     this.Cpu = cpu;
     this.Ram = ram;
     this.HardDrives = hardDrives;
     this.VideoCard = videoCard;
     this.battery = battery;
 }
Пример #28
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;
        }
Пример #29
0
 void UpdateColor(ComputerType type)
 {
     switch(type) {
     case ComputerType.Good:
         renderer.material.color = TypeColors[0];
         break;
     case ComputerType.Bad:
         renderer.material.color = TypeColors[1];
         break;
     case ComputerType.Neutral:
         renderer.material.color = TypeColors[2];
         break;
     }
 }
Пример #30
0
        public IComputer CreateComputer(ComputerType type)
        {
            switch (type)
            {
            case ComputerType.GamingPC:
                return(new HpGamingPC());

            case ComputerType.WorkStation:
                return(new HpWorkStation());

            default:
                return(null);
            }
        }
        internal Computer(ComputerType type, Cpu cpu, Rammstein ram, IEnumerable<HardDriver> hardDrives, HardDriver 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;
        }
Пример #32
0
        public IComputer SellComputer(ComputerProducer producer, ComputerType type)
        {
            IComputerFactory factory = null;

            if (producer == ComputerProducer.DELL)
            {
                factory = DellComputerFactory.Instance;
            }
            else if (producer == ComputerProducer.HP)
            {
                factory = HpComputerFactory.Instance;
            }
            return(factory?.CreateComputer(type));
        }
Пример #33
0
            public void ComputerTypeRand()
            {
                Random rand    = new Random((int)DateTime.Now.Ticks);
                int    counter = rand.Next(100);

                if (counter % 2 == 0)
                {
                    computerType = ComputerType.Notebook;
                }
                else
                {
                    computerType = ComputerType.Desktop;
                }
            }
Пример #34
0
        // GET: Admin/ComputerTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ComputerType computerType = db.ComputerType.Find(id);

            if (computerType == null)
            {
                return(HttpNotFound());
            }
            return(View(computerType));
        }
Пример #35
0
        public static void UpdateComputerType(this ComputerType computerType, ComputerTypeViewModel computerTypeVm)
        {
            computerType.ComputerTypeId          = computerTypeVm.ComputerTypeId;
            computerType.ComputerTypeCode        = computerTypeVm.ComputerTypeCode;
            computerType.ComputerTypeName        = computerTypeVm.ComputerTypeName;
            computerType.ComputerTypeDescription = computerTypeVm.ComputerTypeDescription;

            computerType.CreatedDate     = computerTypeVm.CreatedDate;
            computerType.CreatedBy       = computerTypeVm.CreatedBy;
            computerType.UpdatedDate     = computerTypeVm.UpdatedDate;
            computerType.UpdatedBy       = computerTypeVm.UpdatedBy;
            computerType.MetaKeyword     = computerTypeVm.MetaKeyword;
            computerType.MetaDescription = computerTypeVm.MetaDescription;
            computerType.Status          = computerTypeVm.Status;
        }
Пример #36
0
        // GET: Admin/ComputerTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ComputerType computerType = db.ComputerType.Find(id);

            if (computerType == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SubUnitID = new SelectList(db.SubUnit, "ID", "Title", computerType.SubUnitID);
            return(View(computerType));
        }
Пример #37
0
 public Computer(
     ComputerType typeOfComputer, 
     CPU cpuOfComputer, 
     RAM ramOfComputer, 
     HardDrive hardDriveOfComputer, 
     VideoCard videoCardOfComputer, 
     Battery laptopBattery)
 {
     this.TypeOfComputer = typeOfComputer;
     this.CpuOfComputer = cpuOfComputer;
     this.RamOfComputer = ramOfComputer;
     this.HardDriveOfComputer = hardDriveOfComputer;
     this.VideoCardOfComputer = videoCardOfComputer;
     this.LaptopBattery = laptopBattery;
 }
Пример #38
0
 public AbstractComputer(ComputerType type, CPU cpu, RAM ram, IEnumerable<HardDrive> hardDrives, VideoCard videoCard, IBattery battery, IMotherboard motherBoard)
 {
     this.MachineType = type;
     this.Cpu = cpu;
     this.Ram = ram;
     this.HardDrives = hardDrives;
     //// TODO: BUG was here
     ////if (type != ComputerType.LAPTOP && type != ComputerType.PC)
     ////{
     ////    VideoCard.IsMonochrome = true;
     ////}
     this.VideoCard = videoCard;
     this.Battery = battery;
     this.Motherboard = motherBoard;
 }
Пример #39
0
 public IComputer Manufacture(ComputerType type)
 {
     if (type == ComputerType.Laptop)
     {
         return ManufactureLaptop();
     }
     else if (type == ComputerType.PC)
     {
         return ManufacturePC();
     }
     else
     {
         return ManufactureServer();
     }
 }
Пример #40
0
        public static Computer GetComputer(ComputerType computerType)
        {
            RamMemory ram;
            VideoCard videoCard;
            Cpu cpu;

            switch (computerType)
            {
                case ComputerType.Pc:
                    {
                        ram = new RamMemory(DefaultRamSize / 4);
                        videoCard = new VideoCard()
                        {
                            IsMonochrome = false
                        };

                        cpu = new Cpu(DefaultRamSize / 4, ThirtyTwoBitsArchitecture, ram);
                        var computerHardDrivers = new[] { new HardDriver(500, false, 0, null) };
                        return new Computer(computerType, cpu, ram, computerHardDrivers, videoCard, null);
                    }

                case ComputerType.Server:
                    {
                        ram = new RamMemory(DefaultRamSize * 4);
                        videoCard = new VideoCard();
                        cpu = new Cpu(DefaultRamSize / 2, ThirtyTwoBitsArchitecture, ram);
                        var serverHardDrivers = new List<HardDriver> { new HardDriver(0, true, 2, new List<HardDriver> { new HardDriver(1000, false, 0, null), new HardDriver(1000, false, 0, null) }) };

                        return new Computer(computerType, cpu, ram, serverHardDrivers, videoCard, null);
                    }

                case ComputerType.Laptop:
                    {
                        ram = new RamMemory(DefaultRamSize / 2);
                        videoCard = new VideoCard()
                        {
                            IsMonochrome = false
                        };
                        cpu = new Cpu(DefaultRamSize / 4, ThirtyTwoBitsArchitecture * 2, ram);
                        var laptopHardDriver = new[] { new HardDriver(500, false, 0, null) };

                        return new Computer(computerType, cpu, ram, laptopHardDriver, videoCard, new LaptopBattery());
                    }

                default:
                    throw new ArgumentException();
            }
        }
 internal Computer(ComputerType type, Cpu cpu, Ram ram, IEnumerable <HardDrive> hardDrives, VideoCard videoCard, LaptopBatteryReal 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;
 }
Пример #42
0
 public Computer(ComputerType type)
 {
     computerType = type;
 }
Пример #43
0
 /// <summary>
 /// Criando o waypoint.
 /// </summary>
 public Computer(int pId, GameObject pObject, ComputerType pType)
     : base(pId, pObject)
 {
     this._type = pType;
 }