Пример #1
0
 public string AddAstronaut(string type, string astronautName)
 {
     if (type == "Biologist")
     {
         IAstronaut astronaut = new Biologist(astronautName);
         astronautRepository.Add(astronaut);
         return($"Successfully added {type}: {astronautName}!");
     }
     else if (type == "Geodesist")
     {
         IAstronaut astronaut = new Geodesist(astronautName);
         astronautRepository.Add(astronaut);
         return($"Successfully added {type}: {astronautName}!");
     }
     else if (type == "Meteorologist")
     {
         IAstronaut astronaut = new Meteorologist(astronautName);
         astronautRepository.Add(astronaut);
         return($"Successfully added {type}: {astronautName}!");
     }
     else
     {
         throw new InvalidOperationException("Astronaut type doesn't exists!");
     }
 }
Пример #2
0
        public string AddAstronaut(string type, string astronautName)
        {
            string     result;
            IAstronaut astronaut;

            if (type == "Biologist")
            {
                astronaut = new Biologist(astronautName);
                result    = string.Format(Utilities.Messages.OutputMessages.AstronautAdded, type, astronautName);
                astronauts.Add((Astronaut)astronaut);
            }
            else if (type == "Geodesist")
            {
                astronaut = new Geodesist(astronautName);
                result    = string.Format(Utilities.Messages.OutputMessages.AstronautAdded, type, astronautName);
                astronauts.Add((Astronaut)astronaut);
            }
            else if (type == "Meteorologist")
            {
                astronaut = new Meteorologist(astronautName);
                result    = string.Format(Utilities.Messages.OutputMessages.AstronautAdded, type, astronautName);
                astronauts.Add((Astronaut)astronaut);
            }
            else
            {
                result = Utilities.Messages.ExceptionMessages.InvalidAstronautType;
            }

            return(result);
        }
Пример #3
0
 public string AddAstronaut(string type, string astronautName)
 {
     if (type == "Biologist")
     {
         Biologist biologist = new Biologist(astronautName);
         AstronautRepository.Add(biologist);
         return($"Successfully added {type}: {astronautName}!");
     }
     else if (type == "Geodesist")
     {
         Geodesist geodesist = new Geodesist(astronautName);
         AstronautRepository.Add(geodesist);
         return($"Successfully added {type}: {astronautName}!");
     }
     else if (type == "Meteorologist")
     {
         Meteorologist meteorologist = new Meteorologist(astronautName);
         AstronautRepository.Add(meteorologist);
         return($"Successfully added {type}: {astronautName}!");
     }
     else
     {
         return(null);
     }
 }
Пример #4
0
        public string AddAstronaut(string type, string astronautName)
        {
            IAstronaut astronaut;

            switch (type)
            {
            case "Biologist":
                astronaut = new Biologist(astronautName);
                break;

            case "Geodesist":
                astronaut = new Geodesist(astronautName);
                break;

            case "Meteorologist":
                astronaut = new Meteorologist(astronautName);
                break;

            default:
                throw new InvalidOperationException(ExceptionMessages.InvalidAstronautType);
            }

            astronautRepository.Add(astronaut);
            return($"Successfully added {type}: {astronautName}!");
        }
        public string AddAstronaut(string type, string astronautName)
        {
            IAstronaut astronaut = null;

            switch (type)
            {
            case "Biologist":
                astronaut = new Biologist(astronautName);
                break;

            case "Geodesist":
                astronaut = new Geodesist(astronautName);
                break;

            case "Meteorologist":
                astronaut = new Meteorologist(astronautName);
                break;

            default:
                throw new InvalidOperationException(ExceptionMessages.InvalidAstronautType);
            }

            astronautRepository.Add(astronaut);

            return(string.Format(OutputMessages.AstronautAdded, astronaut.GetType().Name, astronautName));
        }
Пример #6
0
        public string AddAstronaut(string type, string astronautName)
        {
            IAstronaut astronaut = null;

            if (type == "Biologist")
            {
                astronaut = new Biologist(astronautName);
            }
            else if (type == "Geodesist")
            {
                astronaut = new Geodesist(astronautName);
            }
            else if (type == "Meteorologist")
            {
                astronaut = new Meteorologist(astronautName);
            }
            else
            {
                throw new InvalidOperationException(ExceptionMessages.InvalidAstronautType);
            }
            astronautRepository.Add(astronaut);

            return(string.Format(OutputMessages.AstronautAdded,
                                 astronaut.GetType().Name,
                                 astronaut.Name));
        }
Пример #7
0
        public string AddAstronaut(string type, string astronautName)
        {
            if (type == "Geodesist")
            {
                astronauts.Add(new Geodesist(astronautName));
            }
            else if (type == "Biologist")
            {
                astronauts.Add(new Biologist(astronautName));
            }
            else if (type == "Meteorologist")
            {
                astronauts.Add(new Meteorologist(astronautName));
            }
            else if (true)
            {
                throw new InvalidOperationException(ExceptionMessages.InvalidAstronautType);
            }

            return($"Successfully added {type}: {astronautName}!");
        }
Пример #8
0
        public string AddAstronaut(string type, string astronautName)
        {
            if (!AstronautValidatorType.ValidateAstronautType(type))
            {
                throw new InvalidOperationException(ExceptionMessages.InvalidAstronautType);
            }

            var newAstronaut = AstronautFactory.CreateAstronaut(type, astronautName);

            astrRepo.Add(newAstronaut);

            return(string.Format(OutputMessages.AstronautAdded, type, astronautName));
        }