Exemple #1
0
    public void DriverBoxes(List <string> commandArgs)
    {
        var reason     = commandArgs[0];
        var driverName = commandArgs[1];

        var driver = this.drivers.SingleOrDefault(x => x.Name == driverName);

        driver.ChangeTotalTime(20);

        if (reason == "ChangeTyres")
        {
            var tyreType     = commandArgs[2];
            var tyreHardness = double.Parse(commandArgs[3]);

            var tyre = TyreFactory.Get(commandArgs.Skip(2).Take(3).ToList());

            if (tyre != null)
            {
                driver.Car.ChangeTyre(tyre);
            }
        }

        if (reason == "Refuel")
        {
            var amount = double.Parse(commandArgs[2]);
            driver.Car.Refuel(amount);
        }
    }
Exemple #2
0
    public void RegisterDriver(List <string> commandArgs)
    {
        try
        {
            var hp         = int.Parse(commandArgs[2]);
            var fuelAmount = double.Parse(commandArgs[3]);

            Tyre tyre = TyreFactory.Get(commandArgs.Skip(4).Take(3).ToList());

            if (tyre == null)
            {
                throw new ArgumentException();
            }

            var car = new Car(hp, fuelAmount, tyre);

            if (car == null)
            {
                throw new ArgumentException();
            }

            Driver driver = DriverFactory.Get(commandArgs.Take(2).ToList(), car);

            if (driver == null)
            {
                throw new ArgumentException();
            }

            this.drivers.Add(driver);
        }
        catch
        {
        }
    }