public string CreateMotorcycle(string type, string model, int horsePower)
        {
            string fullTypeName = $"{type}Motorcycle";

            if (motorcycleRepository.Models.Any(m => m.Model == model))
            {
                throw new ArgumentException(string.Format(ExceptionMessages.MotorcycleExists, model));
            }
            IMotorcycle motorcycle;

            switch (type)
            {
            case "Speed":
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            break;

            default:
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }
            break;
            }

            motorcycleRepository.Add(motorcycle);

            return(string.Format(OutputMessages.MotorcycleCreated, fullTypeName, model));
        }
Esempio n. 2
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            if (this.motorcycleRepository.GetByName(model) != null)
            {
                string output = string.Format(ExceptionMessages.MotorcycleExists, model);
                throw new ArgumentException(output);
            }

            if (type == "Speed")
            {
                SpeedMotorcycle motorcycle = new SpeedMotorcycle(model, horsePower);
                this.motorcycleRepository.Add(motorcycle);

                string result = string.Format(OutputMessages.MotorcycleCreated, motorcycle.GetType().Name, motorcycle.Model);
                return(result);
            }
            else
            {
                PowerMotorcycle motorcycle = new PowerMotorcycle(model, horsePower);
                this.motorcycleRepository.Add(motorcycle);

                string result = string.Format(OutputMessages.MotorcycleCreated, motorcycle.GetType().Name, motorcycle.Model);
                return(result);
            }
        }
 public string CreateMotorcycle(string type, string model, int horsePower)
 {
     if (type == "Speed")
     {
         if (!this.motorcycleRepository.GetAll().Any(n => n.Model == model && n.GetType().Name == "SpeedMotorcycle"))
         {
             this.speedMotorcycle = new SpeedMotorcycle(model, horsePower);
             this.motorcycleRepository.Add(this.speedMotorcycle);
             return($"{this.speedMotorcycle.GetType().Name} {this.speedMotorcycle.Model} is created.");
         }
         else
         {
             throw new ArgumentException($"Motorcycle {model} is already created.");
         }
     }
     else
     {
         if (!this.motorcycleRepository.GetAll().Any(n => n.Model == model && n.GetType().Name == "PowerMotorcycle"))
         {
             this.powerMotorcycle = new PowerMotorcycle(model, horsePower);
             this.motorcycleRepository.Add(this.powerMotorcycle);
             return($"{this.powerMotorcycle.GetType().Name} {this.powerMotorcycle.Model} is created.");
         }
         else
         {
             throw new ArgumentException($"Motorcycle {model} is already created.");
         }
     }
 }
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            var allMotorcycles = this.motorcycleRepository.GetAll();

            foreach (var currMotorcycle in allMotorcycles)
            {
                if (currMotorcycle.Model == model)
                {
                    throw new ArgumentException($"Motorcycle {model} is already created.");
                }
            }

            Motorcycle motorcycle = null;

            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            else if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }

            this.motorcycleRepository.Add(motorcycle);

            return($"{motorcycle.GetType().Name} {model} is created.");
        }
        } // TODO: Repair

        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            IMotorcycle motorcycle = null;

            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            else if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }

            foreach (var m in motorcycles.GetAll())
            {
                if (m.Model == motorcycle.Model)
                {
                    throw new ArgumentException($"Motorcycle {m.Model} is already created.");
                }
            }

            motorcycles.Add(motorcycle);

            return(string.Format(OutputMessages.RiderCreated, motorcycle.GetType().Name, motorcycle.Model));
        }
Esempio n. 6
0
        public static void Main(string[] args)
        {
            //TODO Add IEngine
            Motorcycle varche = new PowerMotorcycle("12214235", 75);

            Console.WriteLine(varche.HorsePower);
        }
Esempio n. 7
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            //Create a motorcycle with the provided model and horsepower and add it to the repository.
            //There are two types of motorcycles: "SpeedMotorcycle" and "PowerMotorcycle".
            //If the motorcycle already exists in the appropriate repository throw an ArgumentException with following message:
            //"Motorcycle {model} is already created."
            //If the motorcycle is successfully created, the method should return the following message:
            //"{"SpeedMotorcycle"/ "PowerMotorcycle"} {model} is created."
            IMotorcycle motorcycle = this.motorcycleRepository
                                     .GetByName(model);

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

            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            else if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }

            this.motorcycleRepository.Add(motorcycle);

            return($"{motorcycle.GetType().Name} {model} is created.");
        }
Esempio n. 8
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            IMotorcycle moto = null;

            if (type == "Speed")
            {
                moto = new SpeedMotorcycle(model, horsePower);
            }
            else if (type == "Power")
            {
                moto = new PowerMotorcycle(model, horsePower);
            }
            else
            {
                throw new ArgumentException(ExceptionMessages.MotorcycleInvalid);
            }

            var getAll = this.motoRepository.GetByName(model);

            if (getAll != null)
            {
                throw new ArgumentException(string.Format(ExceptionMessages.MotorcycleExists, model));
            }

            this.motoRepository.Add(moto);
            return(string.Format(OutputMessages.MotorcycleCreated, moto.GetType().Name, model));
        }
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            //Could have an issue with the getbyname method
            IMotorcycle motorcycle = null;

            if (type.ToLower() == "speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            else if (type.ToLower() == "power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }

            if (motorcycleRepository.GetByName(motorcycle.Model) != null)
            {
                throw new ArgumentException($"Motorcycle {motorcycle.Model} is already created.");
            }
            else
            {
                motorcycleRepository.Add(motorcycle);

                return($"{motorcycle.GetType().Name} {motorcycle.Model} is created.");
            }
        }
Esempio n. 10
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            if (this.motorcycleRepository.GetByName(model) != null)
            {
                throw new ArgumentException(string.Format(ExceptionMessages.MotorcycleExists, model));
            }

            IMotorcycle motorcycle = null;

            switch (type)
            {
            case "Power":
                motorcycle = new PowerMotorcycle(model, horsePower);
                break;

            case "Speed":
                motorcycle = new SpeedMotorcycle(model, horsePower);
                break;

            default:
                break;
            }

            this.motorcycleRepository.Add(motorcycle);

            return(string.Format(OutputMessages.MotorcycleCreated,
                                 motorcycle.GetType().Name,
                                 motorcycle.Model));
        }
Esempio n. 11
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            if (MotorcycleExistValidator(model))
            {
                //probably mistake with message!
                throw new ArgumentException(string.Format(ExceptionMessages.MotorcycleExists, model));
            }

            if (type.StartsWith("Speed"))
            {
                var motorcycle = new SpeedMotorcycle(model, horsePower);
                this.motorcyles.Add(motorcycle);

                var result = string.Format(OutputMessages.MotorcycleCreated, SpeedMotorcycleType, model);
                return(result);
            }
            else if (type.StartsWith("Power"))
            {
                var motorcycle = new PowerMotorcycle(model, horsePower);
                this.motorcyles.Add(motorcycle);

                var result = string.Format(OutputMessages.MotorcycleCreated, PowerMotorcycleType, model);
                return(result);
            }
            else
            {
                throw new InvalidOperationException("Invalid type");
            }
        }
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            var motorcycle = motorcycleRepository.GetByName(model);

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

            switch (type)
            {
            case "Speed":
                motorcycle = new SpeedMotorcycle(model, horsePower);
                break;

            case "Power":
                motorcycle = new PowerMotorcycle(model, horsePower);
                break;
            }

            motorcycleRepository.Add(motorcycle);

            var result = $"{type}Motorcycle {model} is created.";

            return(result);
        }
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            var motorcycle = motorcycleRepository.GetByName(model);
            var result     = string.Empty;

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

            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);

                motorcycleRepository.Add(motorcycle);

                result = $"SpeedMotorcycle {model} is created.";
            }
            else if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);

                motorcycleRepository.Add(motorcycle);

                result = $"PowerMotorcycle {model} is created.";
            }

            return(result);
        }
Esempio n. 14
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            if (motorcycleRepository.GetByName(model) != null)
            {
                throw new ArgumentException(string.Format(ExceptionMessages.MotorcycleExists, model));
            }
            else
            {
                if (type == "Speed")
                {
                    var motorcycle = new SpeedMotorcycle(model, horsePower);
                    motorcycleRepository.Add(motorcycle);

                    return(string.Format(OutputMessages.MotorcycleCreated, "SpeedMotorcycle", model));
                }
                else if (type == "Power")
                {
                    var motorcycle = new PowerMotorcycle(model, horsePower);
                    motorcycleRepository.Add(motorcycle);

                    return(string.Format(OutputMessages.MotorcycleCreated, "PowerMotorcycle", model));
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 15
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            IMotorcycle motorcycle = null;

            if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }
            else if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            motorcycleRepository.Add(motorcycle);

            return($"{string.Format(OutputMessages.MotorcycleCreated, type + "Motorcycle", model)}");
        }
Esempio n. 16
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            IMotorcycle motorcycle = motorcycleRepository.GetByName(model);

            if (motorcycle != null)
            {
                throw new ArgumentException($"Motorcycle {model} is already created.");
            }
            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            else if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }
            motorcycleRepository.Add(motorcycle);
            return($"{motorcycle.GetType().Name} {model} is created.");
        }
Esempio n. 17
0
        public IMotorcycle CreateMotorcycle(string type, string model, int horsePower)
        {
            type += "Motorcycle";

            IMotorcycle motorcycle = null;

            switch (type)
            {
            case "PowerMotorcycle":
                motorcycle = new PowerMotorcycle(model, horsePower);
                break;

            case "SpeedMotorcycle":
                motorcycle = new SpeedMotorcycle(model, horsePower);
                break;
            }

            return(motorcycle);
        }
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            Motorcycle motorcycle = null;

            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            else if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }
            if (motorcycleRepo.GetAll().Any(x => x.Model == model))
            {
                throw new ArgumentException($"Motorcycle {model} is already created.");
            }
            motorcycleRepo.Add(motorcycle);
            return($"{type}Motorcycle { model} is created.");
        }
Esempio n. 19
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            if ((this.motorcycleRepository.GetByName(model) != null))
            {
                throw new ArgumentException(String.Format(ExceptionMessages.MotorcycleExists, model));
            }
            IMotorcycle motorcycle = null;

            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            else if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }

            this.motorcycleRepository.Add(motorcycle);
            return(String.Format(OutputMessages.MotorcycleCreated, motorcycle.GetType().Name, motorcycle.Model));
        }
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            var motorcycle = motorcycles.GetByName(model);

            if (motorcycle != null)
            {
                throw new ArgumentException(string.Format(ExceptionMessages.MotorcycleExists, model));
            }

            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }

            motorcycles.Add(motorcycle);
            return(string.Format(OutputMessages.MotorcycleCreated, motorcycle.GetType().Name, model));
        }
Esempio n. 21
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            IMotorcycle motorcycle;

            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            else
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }

            if (this.motorcycleRepository.GetAll().Any(m => m.Model == model))
            {
                throw new ArgumentException(string.Format(ExceptionMessages.MotorcycleExists, model));
            }

            this.motorcycleRepository.Add(motorcycle);

            return(string.Format(OutputMessages.MotorcycleCreated, type + "Motorcycle", model));
        }
Esempio n. 22
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            Motorcycle motorcycle = null;

            if (type == "Speed")
            {
                if (horsePower < 50 && 69 < horsePower)
                {
                    throw new ArgumentException($"Invalid horse power: {horsePower}.");
                }
                else
                {
                    motorcycle = new SpeedMotorcycle(model, horsePower);
                }
            }
            else if (type == "Power")
            {
                if (horsePower < 70 && 100 < horsePower)
                {
                    throw new ArgumentException($"Invalid horse power: {horsePower}.");
                }
                else
                {
                    motorcycle = new PowerMotorcycle(model, horsePower);
                }
            }

            if (motorcycleRepository.Models != null && motorcycleRepository.Models.Any(x => x.Model == model))
            {
                throw new ArgumentException($"Motorcycle {model} is already created.");
            }

            if (motorcycle != null)
            {
                motorcycleRepository.Add(motorcycle);
            }

            return($"{motorcycle.GetType().Name} {model} is created.");
        }
Esempio n. 23
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            IMotorcycle motorcycle = null;

            if (type == "Speed")
            {
                motorcycle = new SpeedMotorcycle(model, horsePower);
            }
            else if (type == "Power")
            {
                motorcycle = new PowerMotorcycle(model, horsePower);
            }

            if (motorcycles.GetAll().Any(m => m.Model == model))
            {
                throw new ArgumentException(String.Format(ExceptionMessages.MotorcycleExists, model));
            }

            motorcycles.Add(motorcycle);

            return(String.Format(OutputMessages.MotorcycleCreated, motorcycle.GetType().Name, model));
        }
Esempio n. 24
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            IMotorcycle motorcycle = this.motors.GetByName(model);

            if (motorcycle == null)
            {
                if (type == "Speed")
                {
                    /*SpeedMotorcycle speedMotorcycle*/ motorcycle = new SpeedMotorcycle(model, horsePower);
                }
                else
                {
                    motorcycle = new PowerMotorcycle(model, horsePower);
                }
                this.motors.Add(motorcycle);
                return(string.Format(OutputMessages.MotorcycleCreated, motorcycle.GetType().Name, motorcycle.Model));
            }
            else
            {
                throw new ArgumentException(ExceptionMessages.MotorcycleExists, motorcycle.Model);
            }
        }
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            var motor = this.motorRepo.GetByName(model);

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

            if (type == "Power")
            {
                motor = new PowerMotorcycle(model, horsePower);
            }
            else if (type == "Speed")
            {
                motor = new SpeedMotorcycle(model, horsePower);
            }

            this.motorRepo.Add(motor);

            return($"{motor.GetType().Name} {model} is created.");
        }
Esempio n. 26
0
 public string CreateMotorcycle(string type, string model, int horsePower)
 {
     if (motorcycleRepository.GetByName(model) != null)
     {
         if (type == null)
         {
             if (type == "Power")
             {
                 PowerMotorcycle powerMotorcycle = new PowerMotorcycle(model, horsePower);
                 motorcycleRepository.Add(powerMotorcycle);
                 return($"PowerMotorcycle {model} is created.");
             }
             else if (type == "Speed")
             {
                 PowerMotorcycle powerMotorcycle = new PowerMotorcycle(model, horsePower);
                 motorcycleRepository.Add(powerMotorcycle);
                 return($"SpeedMotorcycle {model} is created.");
             }
         }
     }
     throw new ArgumentException($"Motorcycle {model} is already created.");
 }
Esempio n. 27
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            var listOfMotors = motorRepo.GetAll().ToList();

            if (listOfMotors.Any(x => x.Model == model))
            {
                throw new ArgumentException(string.Format(ExceptionMessages.MotorcycleExists, model));
            }

            if (type == "Speed")
            {
                var newMotorycle = new SpeedMotorcycle(model, horsePower);
                motorRepo.Add(newMotorycle);
                return(string.Format(OutputMessages.MotorcycleCreated, newMotorycle.GetType().Name, model));
            }
            else
            {
                var newMotorycle = new PowerMotorcycle(model, horsePower);
                motorRepo.Add(newMotorycle);
                return(string.Format(OutputMessages.MotorcycleCreated, newMotorycle.GetType().Name, model));
            }
        }
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            var checkIfMotorcycleExist = this.motorcycleRepo.GetByName(model) != null;

            if (checkIfMotorcycleExist)
            {
                throw new ArgumentException($"Motorcycle {model} is already created.");
            }

            Motorcycle newMotorCycle = null;

            if (type == "Power")
            {
                newMotorCycle = new PowerMotorcycle(model, horsePower);
            }
            else if (type == "Speed")
            {
                newMotorCycle = new SpeedMotorcycle(model, horsePower);
            }

            this.motorcycleRepo.Add(newMotorCycle);
            return($"{type}Motorcycle {model} is created.");
        }
Esempio n. 29
0
        public string CreateMotorcycle(string type, string model, int horsePower)
        {
            IMotorcycle motorcycle = this.motorcyclesRepository.GetByName(model);

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

            switch (type)
            {
            case "Speed":
                motorcycle = new SpeedMotorcycle(model, horsePower);
                break;

            case "Power":
                motorcycle = new PowerMotorcycle(model, horsePower);
                break;
            }

            this.motorcyclesRepository.Add(motorcycle);
            return($"{motorcycle.GetType().Name} {motorcycle.Model} is created");
        }