Ejemplo n.º 1
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("Astronaut type doesn't exists!");
            }
            astronautRepository.Add(astronaut);

            return($"Successfully added {type}: {astronautName}!");
        }
Ejemplo n.º 2
0
 public string AddAstronaut(string type, string astronautName)
 {
     if (type == "Biologist")
     {
         IAstronaut bio = new Biologist(astronautName);
         this.astronauts.Add(bio);
         return($"Successfully added {type}: {astronautName}!");
     }
     else if (type == "Geodesist")
     {
         IAstronaut geo = new Geodesist(astronautName);
         this.astronauts.Add(geo);
         return($"Successfully added {type}: {astronautName}!");
     }
     else if (type == "Meteorologist")
     {
         IAstronaut meo = new Meteorologist(astronautName);
         this.astronauts.Add(meo);
         return($"Successfully added {type}: {astronautName}!");
     }
     else
     {
         throw new InvalidOperationException("Astronaut type doesn't exists!");
     }
 }
        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));
        }
Ejemplo n.º 4
0
        public string AddAstronaut(string type, string astronautName)
        {
            if (type != nameof(Biologist) && type != nameof(Geodesist) && type != nameof(Meteorologist))
            {
                throw new InvalidOperationException("Astronaut type doesn't exists!");
            }

            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);
            }

            this.astronautRepository.Add(astronaut);

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

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

            this.astronautRepository.Add(astronaut);

            return(string.Format(OutputMessages.AstronautAdded,
                                 type,
                                 astronautName));
        }
Ejemplo n.º 6
0
        public string AddAstronaut(string type, string astronautName)
        {
            //if (type != nameof(Biologist) || type != nameof(Geodesist) || type != nameof(Meteorologist))
            //{
            //    throw new InvalidOperationException("Astronaut type doesn't exists!");
            //}

            IAstronaut astronautNew  = null;
            string     returnMessage = string.Empty;

            switch (type)
            {
            case nameof(Biologist):
                astronautNew  = new Biologist(astronautName);
                returnMessage = $"Successfully added {type}: {astronautName}!";
                break;

            case nameof(Geodesist):
                astronautNew  = new Geodesist(astronautName);
                returnMessage = $"Successfully added {type}: {astronautName}!";
                break;

            case nameof(Meteorologist):
                astronautNew  = new Meteorologist(astronautName);
                returnMessage = $"Successfully added {type}: {astronautName}!";
                break;

            default:
                throw new InvalidOperationException("Astronaut type doesn't exists!");
            }

            this.astronuatRepository.Add(astronautNew);

            return(returnMessage);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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!");
     }
 }
        public string AddAstronaut(string type, string astronautName)
        {
            IAstronaut astronautNew = null;

            switch (type)
            {
            case nameof(Biologist):
                astronautNew = new Biologist(astronautName);
                break;

            case nameof(Geodesist):
                astronautNew = new Geodesist(astronautName);
                break;

            case nameof(Meteorologist):
                astronautNew = new Meteorologist(astronautName);
                break;

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

            this.astronautRepository.Add(astronautNew);

            return(string.Format(OutputMessages.AstronautAdded, type, astronautName));
        }
Ejemplo n.º 10
0
        public string AddAstronaut(string type, string astronautName)
        {
            IAstronaut astronaut;

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

            this.astronauts.Add(astronaut);

            string result = string.Format(OutputMessages.AstronautAdded, type, astronautName);

            return(result);
        }
Ejemplo n.º 11
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);
     }
 }
Ejemplo n.º 12
0
        public string AddAstronaut(string type, string astronautName)
        {
            string     message   = string.Empty;
            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(string.Format(ExceptionMessages.InvalidAstronautType));
            }

            this.astronauts.Add(astronaut);

            return(string.Format(OutputMessages.AstronautAdded, type, astronautName));
        }
Ejemplo n.º 13
0
        public string AddAstronaut(string type, string astronautName)
        {
            string result = string.Empty;

            if (type == nameof(Biologist))
            {
                IAstronaut bio = new Biologist(astronautName);
                astronautRepository.Add(bio);
                result = $"Successfully added {type}: {astronautName}!";
            }
            else if (type == nameof(Geodesist))
            {
                IAstronaut geo = new Geodesist(astronautName);
                astronautRepository.Add(geo);
                result = $"Successfully added {type}: {astronautName}!";
            }
            else if (type == nameof(Meteorologist))
            {
                IAstronaut meteo = new Meteorologist(astronautName);
                astronautRepository.Add(meteo);
                result = $"Successfully added {type}: {astronautName}!";
            }
            else
            {
                throw new InvalidOperationException("Astronaut type doesn't exists!");
            }

            return(result);
        }
        public string AddAstronaut(string astronautType, string astronautName)
        {
            IAstronaut astronaut;

            switch (astronautType)
            {
            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);
            }

            //Assembly assembly = Assembly.GetExecutingAssembly();

            //var type = assembly
            //    .GetTypes()
            //    .FirstOrDefault(t => t.Name == astronautType);

            //if (type == null)
            //{
            //    throw new InvalidOperationException(ExceptionMessages.InvalidAstronautType);
            //}

            //var astronaut = (IAstronaut)Activator.CreateInstance(type, astronautName);

            this.astronautRepository.Add(astronaut);

            return(string.Format(OutputMessages.AstronautAdded,
                                 astronaut.GetType().Name,
                                 astronaut.Name));
        }
        public IAstronaut CreateAstronaut(string type, string astronautName)
        {
            IAstronaut astronaut;

            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);
            }

            return(astronaut);
        }
Ejemplo n.º 16
0
        public Astronaut Create(string type, string astronautName)
        {
            Astronaut 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:
                break;
            }

            return(astronaut);
        }