public string CreateCar(string type, string model, int horsePower)
        {
            var isInRepo = this.carRepo.GetByName(model);

            if (isInRepo != null)
            {
                throw new ArgumentException($"Car {model} is already created.");
            }

            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }

            if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }


            if (car != null)
            {
                this.carRepo.Add(car);
            }


            return($"{car.GetType().Name} {model} is created.");
        }
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }
            if (carRepository.GetByName(model) != null)
            {
                throw new ArgumentException(String.Format
                                                (ExceptionMessages.CarExists, model));
            }
            if (car == null)
            {
                return(null);
            }
            carRepository.Add(car);
            return(string.Format
                       (OutputMessages.CarCreated, car.GetType().Name, model));
        }
示例#3
0
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = null;

            switch (type)
            {
            case "Muscle":
                car = new MuscleCar(model, horsePower);
                break;

            case "Sports":
                car = new SportsCar(model, horsePower);
                break;
            }

            var car1 = this.cars.GetByName(model);

            if (car1 != null)
            {
                throw new ArgumentException($"Car {model} is already created.");
            }

            this.cars.Add(car);

            return($"{car.GetType().Name} {model} is created.");
        }
示例#4
0
        public string CreateCar(string type, string model, int horsePower)
        {
            type += "Car";

            ICar car = null;

            switch (type)
            {
            case nameof(MuscleCar):
                car = new MuscleCar(model, horsePower);
                break;

            case nameof(SportsCar):
                car = new SportsCar(model, horsePower);
                break;

            default:
                car = null;
                break;
            }

            if (this.carRepository.GetByName(model) != null)
            {
                throw new ArgumentException(string.Format(ExceptionMessages.CarExists, model));
            }

            this.carRepository.Add(car);

            return(string.Format(OutputMessages.CarCreated, type, model));
        }
示例#5
0
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car;
            ICar carFromRepository = carsRepository.GetAll().FirstOrDefault(x => x.Model == model);

            if (type == "Muscle")
            {
                if (carFromRepository != null)
                {
                    throw new ArgumentException(String.Format(ExceptionMessages.CarExists, model));
                }

                car = new MuscleCar(model, horsePower);
                carsRepository.Add(car);
            }
            else if (type == "Sports")
            {
                if (carFromRepository != null)
                {
                    throw new ArgumentException(String.Format(ExceptionMessages.CarExists, model));
                }

                car = new SportsCar(model, horsePower);
                carsRepository.Add(car);
            }

            return(String.Format(OutputMessages.CarCreated, type, model));
        }
        public string CreateCar(string type, string model, int horsePower)
        {
            if (this.carRepository.GetAll().Any(c => c.Model == model))
            {
                throw new ArgumentException(string.Format(ExceptionMessages.CarExists, model)); // TODO: липсва 'd' на 'created'
            }

            ICar car = null;

            switch (type)
            {
            case "Muscle":
                car = new MuscleCar(model, horsePower);
                break;

            case "Sports":
                car = new SportsCar(model, horsePower);
                break;

            default:
                break;
            }

            this.carRepository.Add(car);

            return(string.Format(OutputMessages.CarCreated, car.GetType().Name, car.Model));
        }
示例#7
0
        public string CreateCar(string type, string model, int horsePower)
        {
            var carExist = carRepository.GetByName(model);

            if (carExist != null)
            {
                throw new ArgumentException($"Car {model} is already created.");
            }

            Car car;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }
            else
            {
                return("Greshen tip");
            }

            carRepository.Add(car);
            return($"{car.GetType().Name} {model} is created.");
        }
示例#8
0
        public void NewMuscleCar()
        {
            Driver driver = new MuscleCar("cobaille", "Muscle Car", 20);

            Assert.IsNotNull(driver);
            Assert.IsTrue(driver is MuscleCar);
        }
示例#9
0
        public void PointsCalculator_AddPointsIfAsphalt()
        {
            Driver  driver  = new MuscleCar("cobaille", "Muscle Car", 20);
            Segment segment = new Segment("S turn", GroundType.asphalt);

            driver.Performence = 50;
            driver.PointsCalculator(driver, segment);

            Assert.AreEqual(40, driver.Performence);
        }
示例#10
0
        public void SpeedCalculator_AddsSpeedInList()
        {
            Driver  driver  = new MuscleCar("cobaille", "Muscle Car", 20);
            Segment segment = new Segment("straight line", GroundType.asphalt);
            Weather weather = Weather.Sun;

            driver.SpeedCalculator(driver, segment, weather);

            Assert.AreEqual(1, driver.TimeSpentOnSegment.Count);
        }
示例#11
0
        public void Participants_AddingDriverWithRandom()
        {
            var    drivers = new List <Driver>();
            Driver driver;

            //Act
            driver = new MuscleCar("cobaille", "Muscle Car", 20);
            drivers.Add(driver);

            //assert
            Assert.IsTrue(driver is MuscleCar);
            Assert.IsFalse(driver is F1);
        }
示例#12
0
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }
            carRepository.Add(car);
            return(String.Format(OutputMessages.CarCreated, type + "Car", model));
        }
示例#13
0
        private static ICar CarFabric(string type, string model, int horsePower)
        {
            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }

            return(car);
        }
示例#14
0
        public ICar CreateCar(string type, int hp, string model)
        {
            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, hp);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, hp);
            }

            return(car);
        }
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = default;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else
            {
                car = new SportsCar(model, horsePower);
            }

            carRepository.Add(car);

            return(string.Format(OutputMessages.CarCreated, car.GetType().Name, car.Model));
        }
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }

            carRepository.Add(car);

            return($"{car.GetType().Name + "Car"} {car.Model} is created.");
        }
示例#17
0
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }
            if (CarRepository.Colection.Any(el => el.Model == model))
            {
                throw new ArgumentException(string.Format(ExceptionMessages.CarExists, model));
            }
            CarRepository.Add(car);
            return(string.Format(OutputMessages.CarCreated, car.GetType().Name, model));
        }
示例#18
0
        public string CreateCar(string type, string model, int horsePower)
        {
            if (this.cars.GetByName(model) != null)
            {
                throw new ArgumentException($"Car {model} is already created.");
            }
            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }
            this.cars.Add(car);
            return($"{type}Car {model} is created.");
        }
        public string CreateCar(string type, string model, int horsePower)
        {
            if (!this.CarExistence(model))
            {
                if (type == "Muscle")
                {
                    var muscleCar = new MuscleCar(model, horsePower);
                    this.carRep.Add(muscleCar);
                }
                else if (type == "Sports")
                {
                    var sportsCar = new SportsCar(model, horsePower);
                    this.carRep.Add(sportsCar);
                }

                return(string.Format(OutputMessages.CarCreated, type + "Car", model));
            }

            throw new ArgumentException(string.Format(ExceptionMessages.CarExists, model));
        }
示例#20
0
        public string CreateCar(string type, string model, int horsePower)
        {
            var currentCar = carsRepository.GetByName(model);

            if (currentCar != null)
            {
                throw new ArgumentException(string.Format(ExceptionMessages.CarExists, model));
            }
            if (type + "Car" == typeof(MuscleCar).Name)
            {
                currentCar = new MuscleCar(model, horsePower);
            }
            else if (type + "Car" == typeof(SportsCar).Name)
            {
                currentCar = new SportsCar(model, horsePower);
            }
            carsRepository.Add(currentCar);

            return(string.Format(OutputMessages.CarCreated, currentCar.GetType().Name, model));
        }
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = null;

            type = type + "Car";

            switch (type)
            {
            case nameof(MuscleCar):
                car = new MuscleCar(model, horsePower);
                break;

            case nameof(SportsCar):
                car = new SportsCar(model, horsePower);
                break;
            }

            carsRepository.Add(car);
            return(string.Format(OutputMessages.CarCreated, type, model));
        }
示例#22
0
        public string CreateCar(string type, string model, int horsePower)
        {
            if (this.carRepo.GetByName(model) != null)
            {
                throw new ArgumentException(string.Format(ExceptionMessages.CarExists, model));
            }

            ICar car = null;

            if (type + "Car" == typeof(MuscleCar).Name)
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type + "Car" == typeof(SportsCar).Name)
            {
                car = new SportsCar(model, horsePower);
            }

            this.carRepo.Add(car);
            return(string.Format(OutputMessages.CarCreated, car.GetType().Name, car.Model));
        }
        public string CreateCar(string type, string model, int horsePower)
        {
            if (this.carRepository.GetByName(model) != null)
            {
                throw new ArgumentException($"Car {model} is already created");
            }

            Car car = null;

            if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }
            else if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }

            this.carRepository.Add(car);

            return(string.Format(OutputMessages.CarCreated, type, model));
        }
示例#24
0
        public string CreateCar(string type, string model, int horsePower)
        {
            Car newCar;

            if (carRepo.GetByName(model) != null)
            {
                throw new ArgumentException
                          ($"Car {model} is already created.");
            }
            if (type == "Muscle")
            {
                newCar = new MuscleCar(model, horsePower);
                carRepo.Add(newCar);
                return($"MuscleCar {model} is created.");
            }
            else
            {
                newCar = new SportsCar(model, horsePower);
                carRepo.Add(newCar);
                return($"SportsCar {model} is created.");
            }
        }
示例#25
0
        public string CreateCar(string type, string model, int horsePower)
        {
            if (cars.GetAll().Any(x => x.Model == model))
            {
                throw new ArgumentException($"Car {model} is already created.");
            }

            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }

            cars.Add(car);

            return($"{car.GetType().Name} {model} is created.");
        }
示例#26
0
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = null;

            switch (type)
            {
            case "Sports":
                car = new SportsCar(model, horsePower);
                break;

            case "Muscle":
                car = new MuscleCar(model, horsePower);
                break;
            }

            if (carRep.GetByName(model) != null)
            {
                throw new ArgumentException(String.Format(ExceptionMessages.CarExists, model));
            }
            carRep.Add(car);
            return(String.Format(OutputMessages.CarCreated, car.GetType().Name, model));
        }
        public string CreateCar(string type, string model, int horsePower)
        {
            if (this.carRepository.GetByName(model) != null) //ако има такава кола
            {
                throw new ArgumentException($"Car {model} is already created.");
            }

            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }

            this.carRepository.Add(car);

            return($"{car.GetType().Name} {model} is created.");
        }
示例#28
0
        public string CreateCar(string type, string model, int horsePower)
        {
            if (cars.Any(x => x.Model == model))
            {
                string exeption = string.Format(ExceptionMessages.CarExists, model);
                throw new ArgumentException(exeption);
            }

            ICar car = null;

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }

            cars.Add(car);

            return(string.Format(OutputMessages.CarCreated, car.GetType().Name, car.Model));
        }
示例#29
0
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = this.cars.GetByName(model);

            if (car != null)
            {
                string msg1 = String.Format(ExceptionMessages.CarExists, model);
                throw new ArgumentException(msg1);
            }

            if (type == "Muscle")
            {
                car = new MuscleCar(model, horsePower);
            }
            else if (type == "Sports")
            {
                car = new SportsCar(model, horsePower);
            }
            this.cars.Add(car);
            string msg = String.Format(OutputMessages.CarCreated, car.GetType().Name, model);

            return(msg);
        }
        public string CreateCar(string type, string model, int horsePower)
        {
            ICar car = null;

            switch (type)
            {
            case "Muscle":
                car = new MuscleCar(model, horsePower);
                break;

            case "Sports":
                car = new SportsCar(model, horsePower);
                break;
            }

            if (cars.Models.Contains(cars.Models.FirstOrDefault(c => c.Model == model)))
            {
                throw new ArgumentException(string.Format(ExceptionMessages.CarExists, car.GetType().Name));
            }

            cars.Models.Add(car);

            return($"{car.GetType().Name} {car.Model} is created.");
        }