Ejemplo n.º 1
0
        static void Main(string[] args)

        //Console Main Menuboard
        {
            CLI.DisplayWelcome();

            int option = 0;

            while ((option = Menu.Prompt()) != 3)
            {
                switch (option)
                {
                case 1:
                    AddBeerRecipes();
                    break;

                case 2:
                    DisplayBeerRecipeList();
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        internal static int Prompt()
        {
            bool   valid        = false;
            int    parsedOption = 0;
            string option       = string.Empty;

            Display();
            do
            //user prompt to select a valid option if false it will return not valid response
            {
                option = CLI.Prompt($"Please select an option (1-{_options.Length}): ");
                bool canParse = int.TryParse(option, out parsedOption);
                valid = canParse && parsedOption > 0 && parsedOption <= 3;

                if (!valid)
                {
                    Console.WriteLine("'" + option + "' is not a valid option. Please provide a number 1-3");
                }
            }while (!valid);

            return(parsedOption);
        }
Ejemplo n.º 3
0
        static void AddBeerRecipes()
        //Code prompts user to add their own beer recipe ingredient list
        {
            bool          done             = false;
            string        currentdirectory = Directory.GetCurrentDirectory();
            DirectoryInfo directory        = new DirectoryInfo(currentdirectory);
            var           fileName         = Path.Combine(directory.FullName, "beer-recipes.json");

            do
            {
                string beerName = CLI.Prompt("What's the name of your Beer?");
                string Grain    = CLI.Prompt("Add Quantity and Name of Grains?");
                string Malt     = CLI.Prompt("Add Quantity and Name of Malt?");
                string Hops     = CLI.Prompt("Add Quantity and Name of Hops?");
                string Yeast    = CLI.Prompt("Add Quantity and Name of Yeast?");

                _beer.Add(new BeerRecipes {
                    Name = beerName, Grain = Grain, Malt = Malt, Hops = Hops, Yeast = Yeast,
                });
                Serializebeernames(fileName, _beer);
                done = CLI.Prompt("Add another Beer? (y/n) ").ToLower() != "y";
            } while (!done);
        }