public static int PickSurfaceWater()
        {
            Console.WriteLine($"Which surface water % do you prefer? \n" +
                              $"Select 1 for Small (0%-29.99%)\n" +
                              $"Select 2 for Medium(30%-59.9%) \n" +
                              $"Select 3 for Large(60.0%+)");
            ReadLine : var waterPick = Console.ReadLine();
            bool success = Int32.TryParse(waterPick, out int waterPickParse);

            if (success)
            {
            }
            else
            {
                Confirmations.NotANumber(); //Ensures input can be converted into an int.
                goto ReadLine;
            }
            if (waterPickParse < 1 || waterPickParse > 3) //Ensures number selected is within scope.
            {
                Confirmations.WithinRange();
                goto ReadLine;
            }
            else
            {
                return(waterPickParse);
            }
        }
        public static int PickPopulation()
        {
            Console.WriteLine($"Which population size do you prefer? \n" +
                              $"Select 1 for Small (Less than 10 million)\n" +
                              $"Select 2 for Medium (Between 10 million and 2.999 billion)\n" +
                              $"Select 3 for Large (3 billion +)");
            ReadLine : var popPick = Console.ReadLine();                  //reads the population selected.
            bool success = Int32.TryParse(popPick, out int popPickParse); //Parses the biome to an int to be used in the PickMyPlanet method.

            if (success)
            {
            }
            else
            {
                Confirmations.NotANumber();
                goto ReadLine;
            }
            if (popPickParse < 1 || popPickParse > 3) //Ensures number selected is within scope.
            {
                Confirmations.WithinRange();
                goto ReadLine;
            }
            else
            {
                return(popPickParse);
            }
        }
Exemplo n.º 3
0
        public static void DisplayMainMenu()
        {
            Console.WriteLine("-------------------------------------------------------------------------" +
                              "\nPlease select an option below:                                          ||\n" +
                              "[1]: Display a list of all current planets.                             ||\n" +
                              "[2]: Show some superlatives about the planets.                          ||\n" +
                              "[3]: Create a new planet                                                ||\n" +
                              "[4]: Edit an existing planet                                            ||\n" +
                              "[5]: Delete an existing planet                                          ||\n" +
                              "[6]: Answer a few questions to find a Star Wars planet that suits you!  ||\n" +
                              "[7]: Exit program                                                       ||" +
                              "\n-------------------------------------------------------------------------");
            var fileName     = ReadDocument.ReadFileforPath(); //calls read file path method to get to the directory that contains the csv and saves it as a string.
            var mainMenuPick = Console.ReadLine();             //prompts user input to get a selection.
            var success      = Int32.TryParse(mainMenuPick, out int mainMenuSelectionParse);

            if (success)
            {
                if (mainMenuSelectionParse == 1) //Called methods here and below instead of using the if statements in case I ever want to expand the program to be able to call a method without relying on user input.
                {
                    ListofPlanets(fileName);     //List planets
                }
                if (mainMenuSelectionParse == 2)
                {
                    Superlatives(fileName); //List superlatives
                }
                if (mainMenuSelectionParse == 3)
                {
                    CreateAPlanet(fileName); //Create a planet
                }
                if (mainMenuSelectionParse == 4)
                {
                    EditAPlanet(fileName); //Edit a planet
                }
                if (mainMenuSelectionParse == 5)
                {
                    DeleteAPlanet(fileName); //Delete a planet
                }
                if (mainMenuSelectionParse == 6)
                {
                    PickMyPlanet(fileName); //Primary intended function, helps user find a planet they might be interested after a short quiz.
                }
                if (mainMenuSelectionParse == 7)
                {
                    Environment.Exit(0); //Exits program.
                }
                else
                {
                    Confirmations.WithinRange(); //confirms within range.
                }
            }
            else
            {
                Confirmations.NotANumber(); //Confirms user input is a number.
            }
        }
        public static int PickBiome(List <string> biome)
        {
            int counter = 0;

            if (BiomeDict.Count == 0) //checks to verify the dict is empty.
            {
                foreach (var i in biome)
                {
                    Console.WriteLine($"Key {counter} to select {biome[counter]}"); //Prompts the user to select a biome.
                    Calculations.BiomeDict.Add(counter, biome[counter]);            //Adds each to a dictionary to be used in the PickMyPlanet scoring system.
                    counter++;
                }
            }
            else
            {
                Console.WriteLine("Please select an additional biome!");
            }

            ReadLine : var biomePick = Console.ReadLine();                    //reads the Biome selected.
            bool success = Int32.TryParse(biomePick, out int biomePickParse); //Parses the biome to an int to be used in the PickMyPlanet method.

            if (success)
            {
            }
            else
            {
                Confirmations.NotANumber();
                goto ReadLine;
            }
            if (biomePickParse > BiomeDict.Count || biomePickParse < 0)
            {
                Confirmations.WithinRange();
                goto ReadLine;
            }
            else
            {
                return(biomePickParse);
            }
        }