Beispiel #1
0
    public void RegisterDriver(List <string> commandArgs)
    {
        try
        {
            var    driverType   = commandArgs[0];
            var    driverName   = commandArgs[1];
            var    hp           = int.Parse(commandArgs[2]);
            var    fuelAmount   = double.Parse(commandArgs[3]);
            var    tyreType     = commandArgs[4];
            var    tyreHardness = double.Parse(commandArgs[5]);
            var    grip         = 0.0;
            Driver driver       = null;
            Car    car          = null;
            Tyre   tyre         = null;
            if (tyreType == "Ultrasoft")
            {
                grip = double.Parse(commandArgs[6]);
                tyre = TyreFactory.CreateUltraSoft(tyreHardness, grip);
            }
            else if (tyreType == "Hard")
            {
                tyre = TyreFactory.CreateHard(tyreHardness);
            }

            car    = CarFactory.CreateCar(hp, fuelAmount, tyre);
            driver = DriverFactory.CreateDriver(driverType, driverName, car);

            this.drivers.Add(driver);
        }
        catch
        {
        }
    }
Beispiel #2
0
    public void DriverBoxes(List <string> commandArgs)
    {
        var reason     = commandArgs[0];
        var driverName = commandArgs[1];
        var driver     = this.drivers.FirstOrDefault(d => d.Name == driverName);

        driver.IncreaseByInterval(20);
        if (reason == "Refuel")
        {
            driver.BoxForRefuel(double.Parse(commandArgs[2]));
        }
        if (reason == "ChangeTyres")
        {
            var tyreType = commandArgs[2];
            if (tyreType == "Hard")
            {
                driver.BoxForTyres(TyreFactory.CreateHard(double.Parse(commandArgs[3])));
            }
            if (tyreType == "Ultrasoft")
            {
                driver.BoxForTyres(TyreFactory.CreateUltraSoft(double.Parse(commandArgs[3]), double.Parse(commandArgs[4])));
            }
        }
    }