Exemplo n.º 1
0
    public void Tune(int tuneIndex, string addOn)
    {
        int[] indices = this.garage.ParkedCars.Select(a => a.Key).ToArray();

        if (this.garage.ParkedCars.Count > 0)
        {
            for (int i = 0; i < this.garage.ParkedCars.Count; i++)
            {
                this.garage.ParkedCars[indices[i]].Horsepower += tuneIndex;
                this.garage.ParkedCars[indices[i]].Suspension += (tuneIndex * 50) / 100;

                if (this.garage.ParkedCars[indices[i]].GetType().Name == "ShowCar")
                {
                    ShowCar showCar = (ShowCar)this.garage.ParkedCars[indices[i]];

                    showCar.Stars += tuneIndex;

                    this.garage.ParkedCars[indices[i]] = showCar;
                }
                else
                {
                    PerformanceCar performanceCar = (PerformanceCar)this.garage.ParkedCars[indices[i]];

                    performanceCar.AddOns.Add(addOn);

                    this.garage.ParkedCars[indices[i]] = performanceCar;
                }
            }
        }
    }
Exemplo n.º 2
0
    public void Tune(int tuneIndex, string addOn)
    {
        if (!garage.ParkedCars.Any())
        {
            return;
        }

        int horsepowerIncrease = tuneIndex;
        int suspensionIncrease = (tuneIndex * 50) / 100;

        for (int i = 0; i < garage.ParkedCars.Count; i++)
        {
            Car parkedCar = garage.ParkedCars[i];

            parkedCar.Horsepower += horsepowerIncrease;
            parkedCar.Suspension += suspensionIncrease;

            if (parkedCar is ShowCar)
            {
                ShowCar showCar = parkedCar as ShowCar;

                showCar.Stars = (showCar.Stars + tuneIndex);
            }
            else
            {
                PerformanceCar performanceCar = parkedCar as PerformanceCar;

                performanceCar.AddOns.Add(addOn);
            }
        }
    }
    public void Tune(long tuneIndex, string addOn)
    {
        if (garage.ParkedCars.Count != 0)
        {
            foreach (var car in garage.ParkedCars)
            {
                car.Value.HorsePower += tuneIndex;
                car.Value.Suspension += tuneIndex * 50 / 100;

                string carType = car.Value.GetType().Name;
                switch (carType)
                {
                case "ShowCar":
                    ShowCar showCar = ((ShowCar)car.Value);
                    showCar.Stars += tuneIndex;
                    break;

                case "PerformanceCar":
                    PerformanceCar performanceCar = ((PerformanceCar)car.Value);
                    performanceCar.AddOns.Add(addOn);
                    break;
                }
            }
        }
    }
Exemplo n.º 4
0
 public void Register(int id, string type, string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, int durability)
 {
     if (type.Equals("Performance"))
     {
         Car car = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
         this.cars.Add(id, car);
     }
     else if (type.Equals("Show"))
     {
         Car car = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
         this.cars.Add(id, car);
     }
 }
Exemplo n.º 5
0
 public static void Register(int id, string type, string brand, string model, int yearOfProduction, int horsepower,
                             int acceleration, int suspension, int durability)
 {
     if (type == "Performance")
     {
         var performanceCar = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability, 0, false, false);
         allCars.Add(id, performanceCar);
     }
     else
     {
         var showCar = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability, 0, false, false);
         allCars.Add(id, showCar);
     }
 }
    public void Register(int id, string type, string brand, string model, int productionYear, int horsePower, int acceleration, int suspension, int durability)
    {
        switch (type)
        {
        case "Performance":
            cars[id] = new PerformanceCar(brand, model, productionYear, horsePower, acceleration, suspension,
                                          durability, new List <string>());
            break;

        case "Show":
            cars[id] = new ShowCar(brand, model, productionYear, horsePower, acceleration, suspension, durability);
            break;
        }
    }
    private static Car CreateCar(string type, string brand, string model, long yearOfProduction, long horsepower, long acceleration, long suspension, long durability)
    {
        Car car = null;

        if (type == "Show")
        {
            car = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
        }
        else if (type == "Performance")
        {
            car = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
        }

        return(car);
    }
Exemplo n.º 8
0
    public Car CreateCar(string type, string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, int durability)
    {
        Car car = null;

        if (type == "Performance")
        {
            car = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
        }
        else if (type == "Show")
        {
            car = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
        }

        return(car);
    }
Exemplo n.º 9
0
    public void Register(int id, string type, string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, int durability)
    {
        switch (type)
        {
        case "Performance":
            PerformanceCar performanceCar = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            cars.Add(id, performanceCar);
            break;

        case "Show":
            ShowCar showCar = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            cars.Add(id, showCar);
            break;
        }
    }
Exemplo n.º 10
0
    public void Register(int id, string type, string brand, string model, int yearOfProduction, int horsepower,
                         int acceleration, int suspension, int durability)
    {
        Car car = null;

        if (type == "Performance")
        {
            car = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
        }
        else
        {
            car = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
        }
        cars.Add(id, car);
    }
Exemplo n.º 11
0
    public static Car MakeCar(int id, string type, string brand, string model, int yearOfProduction, int horsepower,
                              int acceleration, int suspension, int durability)
    {
        Car car = null;

        switch (type.ToLower())
        {
        case "performance": car = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "show": car = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;
        }

        return(car);
    }
Exemplo n.º 12
0
 public void Tune(int tuneIndex, string addOn)
 {
     foreach (var car in this.garage.ParkedCars)
     {
         car.Value.Horsepower += tuneIndex;
         car.Value.Suspension += tuneIndex / 2;
         if (car.Value.GetType().Name == "ShowCar")
         {
             ShowCar show = (ShowCar)car.Value;
             show.Stars += tuneIndex;
         }
         else
         {
             PerformanceCar perf = (PerformanceCar)car.Value;
             perf.AddOns.Add(addOn);
         }
     }
 }
Exemplo n.º 13
0
 public void CreateCar(int id, string type, string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, int durability)
 {
     if (type == "Performance")
     {
         ICar car = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
         Data.cars.Add(id, car);
     }
     else if (type == "Show")
     {
         ICar car = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension,
                                durability);
         Data.cars.Add(id, car);
     }
     else
     {
         Console.WriteLine("No such type of car");
     }
 }
Exemplo n.º 14
0
 public void Register(int id, string type, string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, int durability)
 {
     if (type == "Performance")
     {
         Car performanceCar = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
         if (!id_Car.ContainsKey(id))
         {
             id_Car.Add(id, performanceCar);
         }
     }
     else//Show
     {
         Car showCar = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability, 0);
         if (!id_Car.ContainsKey(id))
         {
             id_Car.Add(id, showCar);
         }
     }
 }
Exemplo n.º 15
0
    public void Register(int id, string type, string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, int durability)
    {
        Car car;

        switch (type)
        {
        case "Performance":
            car = new PerformanceCar(id, brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "Show":
            car = new ShowCar(id, brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        default:
            throw new InvalidOperationException();
        }
        this.cars.Add(car);
    }
Exemplo n.º 16
0
    public void TuneCars(int tuneIndex, string addOn)
    {
        foreach (var car in parkedCars)
        {
            car.Value.Horsepower += tuneIndex;
            car.Value.Suspension += tuneIndex / 2;

            if (car.Value.GetType().ToString() == "PerformanceCar")
            {
                PerformanceCar perf = (PerformanceCar)car.Value;//cast
                perf.AddOns.Add(addOn);
            }
            else//Show Car
            {
                ShowCar showCar = (ShowCar)car.Value;
                showCar.Stars += tuneIndex;
            }
        }
    }
Exemplo n.º 17
0
    public Car CreateCar(string type, string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, int durability)
    {
        Car newCar = null;

        switch (type)
        {
        case "Performance":
            newCar = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "Show":
            newCar = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        default:
            throw new NotSupportedException();
        }

        return(newCar);
    }
Exemplo n.º 18
0
    public void Register(int id, string type, string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, int durability)
    {
        Car car = null;

        switch (type)
        {
        case "Show":
            car = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "Performance":
            car = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;
        }

        if (!Registered.ContainsKey(id))
        {
            Registered.Add(id, car);
        }
    }
Exemplo n.º 19
0
    public static Car CreateCar(string type, string brand, string model, int year, int horsepower, int acceleration, int suspension, int durability)
    {
        Car car;

        switch (type)
        {
        case "Performance":
            car = new PerformanceCar(brand, model, year, horsepower, acceleration, suspension, durability);
            break;

        case "Show":
            car = new ShowCar(brand, model, year, horsepower, acceleration, suspension, durability);
            break;

        default:
            return(null);
        }

        return(car);
    }
Exemplo n.º 20
0
    public void Register(int id, string type, string brand, string model, int yearOfProduction, int horsepower, int acceleration, int suspension, int durability)
    {
        Car car = null;

        switch (type)
        {
        case "Performance":
            car = new PerformanceCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        case "Show":
            car = new ShowCar(brand, model, yearOfProduction, horsepower, acceleration, suspension, durability);
            break;

        default:
            break;
        }

        if (car != null)
        {
            this.allCars[id] = car;
        }
    }