Example #1
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);
     }
 }
Example #2
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!");
     }
 }
Example #3
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}!");
        }
        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));
        }
Example #5
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 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));
        }
Example #7
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)
        {
            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}!");
        }
Example #9
0
        static void Main(string[] args)
        {
            FileReader     fileReader     = new FileReader();
            Meteorologist  meteorologist  = new Meteorologist();
            WeatherResults weatherResults = new WeatherResults();
            ApiReader      apiReader      = new ApiReader();

            //Console.WriteLine("Hello! Please write the file where your temperature data is stored and separator in the file seperated with a ','.");
            //string input = Console.ReadLine();
            //string[] userInput = input.Split(',');

            //List<TemperatureData> temperatureList = fileReader.CSVReader(userInput[0], Convert.ToChar(userInput[1]));

            //weatherResults.WarmestDataEntry = meteorologist.GetWarmestTemperature(temperatureList);
            //weatherResults.FirstSubZeroEntry = meteorologist.GetFirstBelowZero(temperatureList);
            //weatherResults.MeanValues = meteorologist.GetMeanTemperature(temperatureList);
            //weatherResults.ColdestDataEntry = meteorologist.GetColdestTemperature(temperatureList);

            //Console.WriteLine(weatherResults.GetWeatherResult(temperatureList[0].TimeStamp, temperatureList[temperatureList.Count() - 1].TimeStamp));

            var    apiString         = $"https://opendata-download-metobs.smhi.se/api/version/latest/parameter/1.json";
            var    response          = apiReader.GetAsyncFromApi(apiString);
            var    simpleStationList = fileReader.ReadAirTempRespons(response).GetAwaiter().GetResult();
            string stationJsonArray  = JsonConvert.SerializeObject(simpleStationList);

            System.IO.File.WriteAllText(@"C:\Users\li.wirstrom\Documents\Code is King\FFCG.CodeIsKing\Meteorologist\src\stations.json", stationJsonArray);
        }
Example #10
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);
        }
Example #11
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);
        }
Example #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));
        }
Example #13
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);
        }
        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));
        }
        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);
        }
Example #17
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);
        }
 public void SetUp()
 {
     _fileReader    = new FileReader();
     _meteorologist = new Meteorologist();
 }