public DesktopCPU(double baseFrequency, double boostFrequency, CPUCores cores, string manufacturer, string model, double price, string socket, int tdp, int threads) : base(baseFrequency, boostFrequency, cores, manufacturer, model, tdp, threads) { try { if (price <= 0) { throw new ArgumentException("Price cannot be less or equal to 0. Entered value: " + price.ToString()); } if (string.IsNullOrEmpty(socket) || string.IsNullOrWhiteSpace(socket)) { throw new ArgumentNullException("socket"); } _id = IDGenerator.NextID(); _price = price; _socket = socket; AddToWarehouse(1); } catch (ArgumentNullException exception) { throw exception; } catch (ArgumentException exception) { throw exception; } catch (Exception exception) { throw exception; } }
public CPU(double baseFrequency, double boostFrequency, CPUCores cores, string manufacturer, string model, int tdp, int threads) { try { if (baseFrequency <= 0) { throw new ArgumentException("CPU Base Frequency cannot be less than 0. Entered value: " + baseFrequency.ToString()); } if (boostFrequency < baseFrequency) { throw new ArgumentException("CPU Boost Frequency cannot be less than Base Frequency. Entered value: " + boostFrequency.ToString()); } if (string.IsNullOrEmpty(manufacturer) || string.IsNullOrWhiteSpace(manufacturer)) { throw new ArgumentNullException(manufacturer); } if (string.IsNullOrEmpty(model) || string.IsNullOrWhiteSpace(model)) { throw new ArgumentNullException(model); } if (tdp <= 0) { throw new ArgumentException("TDP cannot be less or equal to 0. Entered value: " + tdp.ToString()); } if (threads != (int)cores && threads != ((int)cores * 2)) { throw new ArgumentException("Number of Threads have to be equal or double of number of cores. Entered value: " + threads.ToString() + ". Number of cores entered: " + cores.ToString()); } _baseFrequency = baseFrequency; _boostFrequency = boostFrequency; _cores = cores; _manufacturer = manufacturer; _model = model; _tdp = tdp; _threads = threads; } catch (ArgumentNullException exception) { throw exception; } catch (ArgumentException exception) { throw exception; } catch (Exception exception) { throw exception; } }
public void TestCPUFactory(decimal baseFrequency, decimal boostFrequency, CPUCores cores, CPUManufacturer manufacturer, string model, string socket, int tdp, int threads) { CPU cpu = CPUFactory.CreateCPU(baseFrequency, boostFrequency, cores, manufacturer, model, socket, tdp, threads); Assert.IsInstanceOf(typeof(CPU), cpu); }
public LaptopCPU(double baseFrequency, double boostFrequency, CPUCores cores, string manufacturer, string model, int tdp, int threads) : base(baseFrequency, boostFrequency, cores, manufacturer, model, tdp, threads) { }
public static CPU CreateCPU(decimal baseFrequency, decimal boostFrequency, CPUCores cores, CPUManufacturer manufacturer, string model, string socket, int tdp, int threads) { return(new CPU(baseFrequency, boostFrequency, cores, manufacturer, model, socket, tdp, threads)); }