Exemplo n.º 1
0
        public string AddRacer(string type, string username, string carVIN)
        {
            Racer racer = null;
            var   car   = this.cars.FindBy(carVIN);

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

            if (type == "ProfessionalRacer")
            {
                racer = new ProfessionalRacer(username, car);
            }
            else if (type == "StreetRacer")
            {
                racer = new StreetRacer(username, car);
            }
            else
            {
                throw new ArgumentException(InvalidRacerType);
            }

            this.racers.Add(racer);
            return(string.Format(SuccessfullyAddedRacer, username));
        }
Exemplo n.º 2
0
        public string AddRacer(string type, string username, string carVIN)
        {
            if (type != "ProfessionalRacer" && type != "StreetRacer")
            {
                throw new ArgumentException(ExceptionMessages.InvalidRacerType);
            }

            IRacer racer = null;
            ICar   car   = carRepository.FindBy(carVIN);

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

            if (type == "ProfessionalRacer")
            {
                racer = new ProfessionalRacer(username, car);
            }
            else if (type == "StreetRacer")
            {
                racer = new StreetRacer(username, car);
            }

            this.racerRepository.Add(racer);

            return(string.Format(OutputMessages.SuccessfullyAddedRacer, username));
        }
Exemplo n.º 3
0
        public string AddRacer(string type, string username, string carVIN)
        {
            Racer racer = default;
            ICar  car   = cars.FindBy(carVIN);

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

            if (type == nameof(ProfessionalRacer))
            {
                racer = new ProfessionalRacer(username, car);
            }
            else if (type == nameof(StreetRacer))
            {
                racer = new StreetRacer(username, car);
            }
            else
            {
                throw new ArgumentException(ExceptionMessages.InvalidRacerType);
            }

            racers.Add(racer);

            return(string.Format(OutputMessages.SuccessfullyAddedRacer, username));
        }
Exemplo n.º 4
0
        public string AddRacer(string type, string username, string carVIN)
        {
            IRacer currentRaces = null;
            ICar   currentCar   = cars.FindBy(carVIN);

            if (currentCar == null)
            {
                throw new ArgumentException("Car cannot be found!");
            }
            if (type == "ProfessionalRacer")
            {
                currentRaces = new ProfessionalRacer(username, currentCar);
                racers.Add(currentRaces);
                return($"Successfully added racer {username}.");
            }
            else if (type == "StreetRacer")
            {
                currentRaces = new StreetRacer(username, currentCar);
                racers.Add(currentRaces);
                return($"Successfully added racer {username}.");
            }
            else
            {
                throw new ArgumentException("Invalid racer type!");
            }
        }
Exemplo n.º 5
0
        public string AddRacer(string type, string username, string carVIN)
        {
            ICar car = cars.FindBy(carVIN);

            if (car is null)
            {
                throw new ArgumentException(ExceptionMessages.CarCannotBeFound);
            }

            IRacer racer;

            switch (type)
            {
            case "ProfessionalRacer":
                racer = new ProfessionalRacer(username, car);
                break;

            case "StreetRacer":
                racer = new StreetRacer(username, car);
                break;

            default:
                throw new ArgumentException(ExceptionMessages.InvalidRacerType);
            }

            racers.Add(racer);
            return(string.Format(OutputMessages.SuccessfullyAddedRacer, username));
        }
Exemplo n.º 6
0
        public string AddRacer(string type, string username, string carVIN)
        {
            ICar car = this.cars.FindBy(carVIN);

            if (car == null)
            {
                throw new ArgumentException("Car cannot be found!");
            }

            if (type != nameof(ProfessionalRacer) && type != nameof(StreetRacer))
            {
                throw new ArgumentException("Invalid racer type!");
            }

            IRacer racer;

            if (type == nameof(ProfessionalRacer))
            {
                racer = new ProfessionalRacer(username, car);
            }
            else
            {
                racer = new StreetRacer(username, car);
            }

            this.racers.Add(racer);
            return(string.Format(OutputMessages.SuccessfullyAddedRacer, racer.Username));
        }
Exemplo n.º 7
0
        public string AddRacer(string type, string username, string carVIN)
        {
            bool success = false;

            foreach (var model in cars.Models)
            {
                if (model.VIN == carVIN)
                {
                    success = true;
                }
            }

            if (success == false)
            {
                throw new ArgumentException(ExceptionMessages.CarCannotBeFound);
            }

            if (type != "ProfessionalRacer" && type != "StreetRacer")
            {
                throw new ArgumentException(ExceptionMessages.InvalidRacerType);
            }

            if (type == "ProfessionalRacer")
            {
                var car = cars.Models.FirstOrDefault(x => x.VIN == carVIN);
                ProfessionalRacer professionalRacer = new ProfessionalRacer(username, car);
            }
            else if (type == "StreetRacer")
            {
                var         car = cars.Models.FirstOrDefault(x => x.VIN == carVIN);
                StreetRacer professionalRacer = new StreetRacer(username, car);
            }

            return($"Successfully added racer {username}.");
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            StreetRacer streetRacer = new StreetRacer();
            Helicoper   helicoper   = new Helicoper();
            Jet         jet         = new Jet();

            streetRacer.Go();
            helicoper.Go();
            jet.Go();
        }