public Tyre CreateTyre(string[] tyreArgs) { var tyreType = tyreArgs[0]; var tyreHardness = double.Parse(tyreArgs[1]); Tyre tyre = null; if (tyreType == "Hard") { tyre = new HardTyre(tyreHardness); } else if (tyreType == "Ultrasoft") { var grip = double.Parse(tyreArgs[2]); tyre = new UltrasoftTyre(tyreHardness, grip); } if (tyre == null) { throw new ArgumentException("Invalid Tyre Type"); } return(tyre); }
public Tyre CreateTyre(List <string> commandArgs) { Tyre newTyre = null; try { switch (commandArgs[0]) { case "Hard": newTyre = new HardTyre(double.Parse(commandArgs[1])); break; case "Ultrasoft": newTyre = new UltrasoftTyre(double.Parse(commandArgs[1]), double.Parse(commandArgs[2])); break; default: break; } } catch (Exception) { } return(newTyre); }
public void DriverBoxes(List <string> commandArgs) { string driverName = commandArgs[1]; var currentDriver = drivers.Where(d => d.Name == driverName).First(); currentDriver.TotalTime += 20; switch (commandArgs[0]) { case "Refuel": double fuelAmout = double.Parse(commandArgs[2]); currentDriver.Car.Refuel(fuelAmout); break; case "ChangeTyres": Tyre tyre = null; double tyreHardness = double.Parse(commandArgs[3]); if (commandArgs[2] == "Hard") { tyre = new HardTyre(tyreHardness); } else if (commandArgs[2] == "Ultrasoft") { double grip = double.Parse(commandArgs[4]); tyre = new UltrasoftTyre(tyreHardness, grip); } currentDriver.Car.ChangeTyre(tyre); break; } }
public Tyre CreateTyre(List <string> commandArgs) { var tyreType = commandArgs[0]; var tyreHardness = double.Parse(commandArgs[1]); var grip = 0.0; if (tyreType == "Ultrasoft") { grip = double.Parse(commandArgs[2]); } Tyre tyre = null; switch (tyreType) { case "Ultrasoft": tyre = new UltrasoftTyre(tyreHardness, grip); break; case "Hard": tyre = new HardTyre(tyreHardness); break; } return(tyre); }
public void DriverBoxes(List <string> commandArgs) { string boxType = commandArgs[0]; string driverName = commandArgs[1]; Driver driver = allDrivers.FirstOrDefault(x => x.Name == driverName); switch (boxType) { case "Refuel": double fuelAmmount = double.Parse(commandArgs[2]); driver.Car.Refuel(fuelAmmount); break; case "ChangeTyres": string tyreType = commandArgs[2]; double hardness = double.Parse(commandArgs[3]); if (tyreType == "Ultrasoft") { double grip = double.Parse(commandArgs[4]); Tyre newTyre = new UltrasoftTyre(hardness, grip); driver.Car.ChangeTyres(newTyre); } else { Tyre newTyre = new HardTyre(hardness); driver.Car.ChangeTyres(newTyre); } break; } }
public void DriverBoxes(List <string> commandArgs) { string action = commandArgs[0]; string name = commandArgs[1]; Driver driver = racingDrivers.FirstOrDefault(d => d.Name == name); driver.AddTime(BOX_TIME); if (action == "Refuel") { double fuel = double.Parse(commandArgs[2]); driver.Car.Refuel(fuel); } else if (action == "ChangeTyres") { double hardness = double.Parse(commandArgs[3]); switch (commandArgs[2]) { case "Hard": HardTyre hardTyre = new HardTyre(hardness); driver.Car.ChangeTyre(hardTyre); break; case "Ultrasoft": double grip = double.Parse(commandArgs[4]); UltrasoftTyre softTyre = new UltrasoftTyre(hardness, grip); driver.Car.ChangeTyre(softTyre); break; } } }
public void DriverBoxes(List <string> arguments) { string command = arguments[0]; string driverName = arguments[1]; this.Drivers[driverName].TotalTime += 20; if (command == "ChangeTyres") { string tyreType = arguments[2]; double hardness = double.Parse(arguments[3]); if (tyreType == "Ultrasoft") { double grip = double.Parse(arguments[4]); Tyre tyre = new UltrasoftTyre(hardness, grip); this.Drivers[driverName].Car.ChangeTyre(tyre); } else if (tyreType == "Hard") { Tyre tyre = new HardTyre(hardness); this.Drivers[driverName].Car.ChangeTyre(tyre); } } else if (command == "Refuel") { double fuelAmount = double.Parse(arguments[2]); this.Drivers[driverName].Car.Refuel(fuelAmount); } }
public Tyre CreateTyre(string[] tyreArgs) { string type = tyreArgs[0] + nameof(Tyre); double hardness = double.Parse(tyreArgs[1]); Tyre tyre = null; switch (type) { case nameof(HardTyre): tyre = new HardTyre(hardness); break; case nameof(UltrasoftTyre): double grip = double.Parse(tyreArgs[2]); tyre = new UltrasoftTyre(hardness, grip); break; default: throw new NotSupportedException(); } return(tyre); }
public Tyre Create(string tyreType, double tyreHardness, double grip) { Tyre tyre = null; tyre = new UltrasoftTyre(tyreHardness, grip); return(tyre); }
public void RegisterDriver(List <string> commandArgs) { var driverType = commandArgs[0]; var tyreType = commandArgs[4]; try { switch (tyreType) { case "Hard": var hardTyre = new HardTyre(double.Parse(commandArgs[5])); var car = new Car(int.Parse(commandArgs[2]), double.Parse(commandArgs[3]), hardTyre); switch (driverType) { case "Aggressive": var agressiveDriver = new AggressiveDriver(commandArgs[1], car); drivers.Add(agressiveDriver); break; case "Endurance": var eduranceDriver = new EnduranceDriver(commandArgs[1], car); drivers.Add(eduranceDriver); break; default: break; } break; case "Ultrasoft": var ultrasoftTyre = new UltrasoftTyre(double.Parse(commandArgs[5]), double.Parse(commandArgs[6])); var car2 = new Car(int.Parse(commandArgs[2]), double.Parse(commandArgs[3]), ultrasoftTyre); switch (driverType) { case "Aggressive": var agressiveDriver = new AggressiveDriver(commandArgs[1], car2); drivers.Add(agressiveDriver); break; case "Endurance": var enduranceDriver = new EnduranceDriver(commandArgs[1], car2); drivers.Add(enduranceDriver); break; default: break; } break; default: break; } } catch (Exception) { return; } }
public static Tyre CreateTyre(string tyreType, double tyreHardness, List <string> commandArgs) { Tyre tyre; if (tyreType == "Hard") { return(tyre = new HardTyre(tyreHardness)); } double grip = double.Parse(commandArgs[6]); return(tyre = new UltrasoftTyre(tyreHardness, grip)); }
public void RegisterDriver(List <string> commandArgs) { try { string type = 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]); if (commandArgs.Count == 6) { Tyre hardTyre = new HardTyre(tyreHardness); Car car = new Car(hp, fuelAmount, hardTyre); if (type == "Aggressive") { Driver aggressiveDriver = new AggressiveDriver(name, car); drivers.Add(aggressiveDriver); } else if (type == "Endurance") { Driver enduranceDriver = new EnduranceDriver(name, car); drivers.Add(enduranceDriver); } } else if (commandArgs.Count == 7) { double grip = double.Parse(commandArgs[6]); Tyre ultraSoftTyre = new UltrasoftTyre(tyreHardness, grip); Car car = new Car(hp, fuelAmount, ultraSoftTyre); if (type == "Aggressive") { Driver aggressiveDriver = new AggressiveDriver(name, car); drivers.Add(aggressiveDriver); } else if (type == "Endurance") { Driver enduranceDriver = new EnduranceDriver(name, car); drivers.Add(enduranceDriver); } } } catch (Exception e) { // FAK U } }
static void Main(string[] args) { // I/O int numberLaps = int.Parse(Console.ReadLine()); int lenghtTrack = int.Parse(Console.ReadLine()); string command; bool IsCompleted = false; while (!IsCompleted) { var splitCommand = Console.ReadLine() .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .ToList(); //RegisterDriver[0] Aggressive[1] FirstDriver[2] 650[3] 140[4] Ultrasoft[5] 0.2[6] 3.8[7] //hardness //grip var typeCommand = splitCommand[0]; switch (typeCommand) { case "RegisterDriver": //variables var name = splitCommand[2]; var fuelAmount = double.Parse(splitCommand[3]); var typeOfTyre = splitCommand[5]; if (splitCommand.Count == 8) { UltrasoftTyre ultrasoftTyre = new UltrasoftTyre(double.Parse(splitCommand[6]), double.Parse(splitCommand[7])); } if (splitCommand[1] == "Aggressive ") { } else { } break; default: break; } } }
public ITyre Produce(List <string> cmdArgs) { var type = cmdArgs[5]; ITyre tyre = null; if (type == "Ultrasoft") { var hardness = double.Parse(cmdArgs[6]); var grip = double.Parse(cmdArgs[7]); tyre = new UltrasoftTyre(hardness, grip); } else if (type == "Hard") { var hardness = double.Parse(cmdArgs[6]); tyre = new HardTyre(hardness); } return(tyre); }
public static Tyre CreateTyre(List <string> tyreArgs) { string type = tyreArgs[0]; double hardness = double.Parse(tyreArgs[1]); Tyre tyre = null; if (type.Equals("Ultrasoft")) { double grip = double.Parse(tyreArgs[2]); tyre = new UltrasoftTyre(hardness, grip); } else if (type.Equals("Hard")) { tyre = new HardTyre(hardness); } return(tyre); }
private Tyre CreateTyre(string[] tyreArgs) { var type = tyreArgs[0]; var hardness = double.Parse(tyreArgs[1]); Tyre tyre = null; if (type == "Hard") { tyre = new HardTyre(hardness); return(tyre); } else if (type == "Ultrasoft") { var grip = double.Parse(tyreArgs[2]); tyre = new UltrasoftTyre(hardness, grip); return(tyre); } throw new ArgumentException(OutputMessages.InvalidTyreType); }
public Tyre CreateTyre(string[] tyreArgs) { string tyreType = tyreArgs[0]; double hardness = double.Parse(tyreArgs[1]); Tyre tyre = null; if (tyreType == "Hard") { tyre = new HardTyre(hardness); } else if (tyreType == "Ultrasoft") { double grip = double.Parse(tyreArgs[2]); tyre = new UltrasoftTyre(hardness, grip); } return(tyre); }
public Tyre CreateTyre(string[] args) { Tyre tyre = null; string type = args[0]; double tyreHardness = double.Parse(args[1]); double tyreGrip = 0d; if (type == "Hard") { tyre = new HardTyre(tyreHardness); } if (type == "Ultrasoft") { tyreGrip = double.Parse(args[2]); tyre = new UltrasoftTyre(tyreHardness, tyreGrip); } return(tyre); }
public Tyre CreateTyre(string[] tyreArgs) { string tyreType = tyreArgs[0]; double tyreHardness = double.Parse(tyreArgs[1]); Tyre tyre = null; if (tyreType == "Hard") { tyre = new HardTyre(tyreHardness); return(tyre); } else if (tyreType == "Ultrasoft") { double grip = double.Parse(tyreArgs[2]); tyre = new UltrasoftTyre(tyreHardness, grip); return(tyre); } throw new ArgumentException(ErrorMessages.InvalidTyreType); }
public Tyre CreateTyre(string[] tyreArgs) { string tyreType = tyreArgs[0]; double tyreHardness = double.Parse(tyreArgs[1]); Tyre tyre = null; if (tyreType == "Hard") { tyre = new HardTyre(tyreHardness); } else if (tyreType == "Ultrasoft") { tyre = new UltrasoftTyre(tyreHardness, double.Parse(tyreArgs[2])); } if (tyre == null) { throw new ArgumentException(OutputMessages.InvalidTyreType); } return(tyre); }
public static Tyre CreateType(List <string> arguments) { var tyreType = arguments[4]; var tyreHardness = double.Parse(arguments[5]); if (tyreType == "Ultrasoft") { var grip = double.Parse(arguments[6]); Tyre tyre = new UltrasoftTyre(tyreHardness, grip); return(tyre); } else if (tyreType == "Hard") { Tyre tyre = new HardTyre(tyreHardness); return(tyre); } else { throw new ArgumentException(); } }
private void ChangeTyres(List <string> commandArgs, IDriver driver) { var type = commandArgs[3]; ITyre newTyre = null; if (type == "Ultrasoft") { var hardness = double.Parse(commandArgs[4]); var grip = double.Parse(commandArgs[5]); newTyre = new UltrasoftTyre(hardness, grip); } else if (type == "Hard") { var hardness = double.Parse(commandArgs[4]); newTyre = new HardTyre(hardness); } if (driver != null) { driver.Car.Tyre = newTyre; } }
public void RegisterDriver(List <string> commandArgs) { string driverType = commandArgs[0]; string name = commandArgs[1]; int hp = int.Parse(commandArgs[2]); double fuelAmmount = double.Parse(commandArgs[3]); string tyreType = commandArgs[4]; double tyreHardness = double.Parse(commandArgs[5]); Tyre tyre = null; if (tyreType == "Ultrasoft") { double tyreGrip = double.Parse(commandArgs[6]); tyre = new UltrasoftTyre(tyreHardness, tyreGrip); } else { tyre = new HardTyre(tyreHardness); } Car car = new Car(hp, fuelAmmount, tyre); Driver driver = null; switch (driverType) { case "Aggressive": driver = new AggressiveDriver(name, car); break; case "Endurance": driver = new EnduranceDriver(name, car); break; default: throw new ArgumentException(); } allDrivers.Add(driver); }
public static Tyre CreateInstance(List <string> args) { try { Tyre newTyre = null; if (args[0] == "Ultrasoft") { newTyre = new UltrasoftTyre(double.Parse(args[1]), double.Parse(args[2])); } else { newTyre = new HardTyre(double.Parse(args[1])); } return(newTyre); } catch { return(null); } }
public Tyre Create(List <string> commandArgs) { Tyre tyre = null; string name = commandArgs[0]; double hardness = double.Parse(commandArgs[1]); double grip = 0; switch (name) { case "Hard": tyre = new HardTyre(hardness); break; case "Ultrasoft": grip = double.Parse(commandArgs[2]); tyre = new UltrasoftTyre(hardness, grip); break; } return(tyre); }
public Tyre GetTyre(string[] arr) { string type = arr[0]; double hardness = double.Parse(arr[1]); Tyre tyre; switch (type) { case "Ultrasoft ": double grip = double.Parse(arr[2]); tyre = new UltrasoftTyre(hardness, grip); break; case "Hard": tyre = new HardTyre(hardness); break; default: return(null); } return(tyre); }
public ITyre CreateTyre(string[] args) { var type = args[0]; var hardness = double.Parse(args[1]); ITyre tyre; switch (type) { case "Ultrasoft": var grip = double.Parse(args[2]); tyre = new UltrasoftTyre(hardness, grip); break; case "Hard": tyre = new HardTyre(hardness); break; default: throw new System.ArgumentException(); } return(tyre); }
public static void RegisterDriver(List <string> commandArgs) { if (commandArgs.Count < 6 && commandArgs.Count > 7) { return; } 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]); Tyre tyre = null; Car car = null; Driver driver = null; if (tyreType == "Ultrasoft") { double grip = double.Parse(commandArgs[6]); // tyre = new UltrasoftTyre(tyreHardness, grip); try { tyre = new UltrasoftTyre(tyreHardness, grip); } catch (Exception ex) { // Console.WriteLine(ex.Message); return; } } else if (tyreType == "Hard") { // tyre = new HardTyre(tyreHardness); try { tyre = new HardTyre(tyreHardness); } catch (Exception ex) { // Console.WriteLine(ex.Message); return; } } else { return; } // car = new Car(hp, fuelAmount, tyre); try { car = new Car(hp, fuelAmount, tyre); } catch (Exception ex) { // Console.WriteLine(ex.Message); return; } if (driverType == "Aggressive") { // driver = new AggressiveDriver(name, car); try { driver = new AggressiveDriver(name, car); } catch (Exception ex) { // Console.WriteLine(ex.Message); return; } } else if (driverType == "Endurance") { // driver = new EnduranceDriver(name, car); try { driver = new EnduranceDriver(name, car); } catch (Exception ex) { // Console.WriteLine(ex.Message); return; } } else { return; } drivers.Add(name, driver); }
public static void DriverBoxes(List <string> commandArgs) { string boxingType = commandArgs[0]; string driverName = commandArgs[1]; Driver driver = null; if (drivers.ContainsKey(driverName) == false) { return; } driver = drivers[driverName]; if (boxingType == "Refuel") { double fuelAmount = double.Parse(commandArgs[2]); try { driver.Car.Refuel(fuelAmount); driver.VisitBox(); } catch (Exception ex) { string failureType = ex.Message; FailDriver(driver.Name, failureType); } } else if (boxingType == "ChangeTyres") { string tyreType = commandArgs[2]; double hardness = double.Parse(commandArgs[3]); Tyre tyre = null; switch (tyreType) { case "Ultrasoft": { double grip = double.Parse(commandArgs[4]); try { tyre = new UltrasoftTyre(hardness, grip); driver.Car.ChangeTyres(tyre); driver.VisitBox(); // driver.IncreaseTotalTime() } catch (Exception ex) { string failureType = ex.Message; FailDriver(driver.Name, failureType); } break; } case "Hard": { try { tyre = new HardTyre(hardness); driver.Car.ChangeTyres(tyre); driver.VisitBox(); } catch (Exception ex) { string failureType = ex.Message; FailDriver(driver.Name, failureType); } break; } } } }