public string CreateComputer(List <string> args) { string name = args[0]; string processorType = args[1]; string processorModel = args[2]; int processorGeneration = int.Parse(args[3]); decimal processorPrice = decimal.Parse(args[4]); string videoCardType = args[5]; string videoCardModel = args[6]; int videoCardGeneration = int.Parse(args[7]); int videoCardRam = int.Parse(args[8]); decimal videoCardPrice = decimal.Parse(args[9]); int computerRam = int.Parse(args[10]); if (users.Any(x => x.Name == name)) { Processor processor = null; if (processorType == "Low") { processor = new LowPerformanceProcessor(processorModel, processorGeneration, processorPrice); } else if (processorType == "High") { processor = new HighPerformanceProcessor(processorModel, processorGeneration, processorPrice); } else { return($"Invalid type processor!"); } VideoCard videoCard = null; if (videoCardType == "Game") { videoCard = new GameVideoCard(videoCardModel, videoCardGeneration, videoCardRam, videoCardPrice); } else if (videoCardType == "Mine") { videoCard = new MineVideoCard(videoCardModel, videoCardGeneration, videoCardRam, videoCardPrice); } else { return($"Invalid type video card!"); } decimal configurationPrice = videoCard.Price + processor.Price; if (configurationPrice > users.First(x => x.Name == name).Money) { return($"User: {name} - insufficient funds!"); } computers.Add(new Computer(processor, videoCard, computerRam)); return($"Successfully created computer for user: {name}!"); } else { return($"Username: {name} does not exist!"); } }
private Processor CreateProcessor(string processorType, string processorModel, int processorGeneration, decimal processorPrice) { Processor processor = null; if (processorType == "Low") { processor = new LowPerformanceProcessor(processorModel, processorGeneration, processorPrice); } else { processor = new HighPerformanceProcessor(processorModel, processorGeneration, processorPrice); } return(processor); }
public static Processor CreateProcessor(List <string> args) { string type = args[0]; string model = args[1]; int generation = int.Parse(args[2]); decimal price = decimal.Parse(args[3]); Processor processor = null; if (type == "Low") { processor = new LowPerformanceProcessor(model, generation, price); } else if (type == "High") { processor = new HighPerformanceProcessor(model, generation, price); } return(processor); }