public Driver Create(List <string> commandArgs) { var type = commandArgs[0]; var name = commandArgs[1]; var hp = int.Parse(commandArgs[2]); var fuelAmount = double.Parse(commandArgs[3]); Tyre tyre = tyreFactory.CreateTyre(commandArgs.Skip(4).ToList()); Car car = new Car(hp, fuelAmount, tyre); Driver driver = null; switch (type) { case "Aggressive": driver = new AggressiveDriver(name, car); break; case "Endurance": driver = new EnduranceDriver(name, car); break; } return(driver); }
public void RegisterDriver(List <string> commandArgs) { string driverType = commandArgs[0]; string name = commandArgs[1]; int hp = int.Parse(commandArgs[2]); double fuelAmount = double.Parse(commandArgs[3]); string tyreType = commandArgs[4]; double tyreHardness = double.Parse(commandArgs[5]); int grip = 0; if (commandArgs.Count > 6) { grip = int.Parse(commandArgs[6]); } Tyre tyre = tyreFactory.CreateTyre(tyreType, tyreHardness, grip); Car car = new Car(hp, fuelAmount, tyre); Driver driver = driverFactory.CreateDriver(driverType, name, car); drivers.Add(driver); }