示例#1
0
        public void AfFactGame()
        {
            try
            {
                MethodLibrary ml = new MethodLibrary();

                Console.Clear();
                ml.PrintColor(ConsoleColor.Yellow, "Welcome to the Facts page");
                ml.PrintColor(ConsoleColor.Yellow, "=========================================\n");


                Random rand = new Random();

                int    factNo = rand.Next(interestingFacts.Length);
                string fact   = interestingFacts[factNo];

                ml.PrintColor(ConsoleColor.Cyan, "\n\n\n" + fact);
                ml.PrintColor(ConsoleColor.Yellow, "\n\n\n Press any key to return to the Random facts menu");
                Console.ReadKey();
                RanFctPg();
            }
            catch (FormatException)
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchFormat();
                RanFctPg();
            }
            catch
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchAll();
                RanFctPg();
            }
        }
示例#2
0
        }   // opens the random facts menu

        public void AboutUs()
        {
            try
            {
                Console.Clear();
                Console.WriteLine("\n\n This Console Application was Developed by Emmanuel Oluyale \n");
                Console.WriteLine(" An initiative of Mr Moshood \n");
                Console.WriteLine(" NIIT.\n\n");
                Console.WriteLine(" Press any key to return to main page");
                Console.ReadKey();
                DisplayMenu();
            }
            catch (FormatException)
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchFormat();
                AboutUs();
            }
            catch
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchAll();
                AboutUs();
            }
        }   // opens the about us page
示例#3
0
        }   // starts the african countries game menu

        public void RanFctPg()
        {
            try
            {
                MethodLibrary ml = new MethodLibrary();
                int           det;
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Clear();
                Console.WriteLine("Welcome to the Random Facts page");
                Console.WriteLine("=========================================\n");
                Console.WriteLine("Enter the associated number to choose an option\n");
                Console.WriteLine("1. Give me an African fact");
                Console.WriteLine("2. Return to Main page");
                Console.WriteLine("3. Quit");

                det = Convert.ToInt32(Console.ReadLine());

                if (det > 3 || det == 0)
                {
                    ml.IfState(3);
                    RanFctPg();
                }

                switch (det)
                {
                case 1:
                    AfFactGame();
                    break;

                case 2:
                    DisplayMenu();
                    break;

                case 3:
                    ml.Exit();
                    break;
                }
            }
            catch (FormatException)
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchFormat();
                RanFctPg();
            }
            catch
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchAll();
                RanFctPg();
            }
        }   // opens the random facts menu
示例#4
0
        public void DisplayMenu()
        {
            try
            {
                MethodLibrary ml = new MethodLibrary();

                int det;

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Clear();
                Console.WriteLine("Welcome to the African countries game Main page");
                Console.WriteLine("========================================================\n");
                Console.WriteLine("Enter the associated number to choose an option\n");
                Console.WriteLine("1. Play African countries game");
                Console.WriteLine("2. Randomized Fact page");
                Console.WriteLine("3. Learn the countries");

                ml.PrintColor(ConsoleColor.DarkCyan, "4. Play Countries of the world");
                ml.PrintColor(ConsoleColor.DarkCyan, "5. Check Highest score");

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("6. About us");
                Console.WriteLine("7. Quit");

                det = Convert.ToInt32(Console.ReadLine());

                if (det > 7 || det == 0)
                {
                    ml.IfState(7);
                    DisplayMenu();
                }

                switch (det)
                {
                case 1:
                    AfConGame();
                    break;

                case 2:
                    RanFctPg();
                    break;

                case 3:
                    PracticeCountries();
                    break;

                case 4:
                    ml.proVersionMessage();
                    DisplayMenu();
                    break;

                case 5:
                    ml.proVersionMessage();
                    DisplayMenu();
                    break;

                case 6:
                    AboutUs();
                    break;

                case 7:
                    ml.Exit();
                    break;
                }
            }
            catch (FormatException)
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchFormat();
                DisplayMenu();
            }
            catch
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchAll();
                DisplayMenu();
            }
        }  // Displays the main menu
示例#5
0
        public void PlayGame()
        {
            try
            {
                MethodLibrary ml = new MethodLibrary();
                Program       p  = new Program();

                bool     det   = false;
                int      score = 0;
                bool     c     = false;
                string   wordUp;
                string   word;
                string[] ArrayerUp = new string[Arrayer.Length];
                string[] compare   = new string[Arrayer.Length];

                Console.Clear();

                do
                {
                    det = false;

                    ml.PrintColor(ConsoleColor.Cyan, " Enter the name of a Country in " + namer + " or press \"quit\" to resign\n");

                    Console.ForegroundColor = ConsoleColor.White;
                    word = Console.ReadLine();
                    Console.ResetColor();

                    wordUp = word.ToUpper();

                    if (wordUp == "QUIT")
                    {
                        break;
                    }

                    for (int i = 0; i < compare.Length; i++)// To verify that user don't entered any word more than once.
                    {
                        if (wordUp == compare[i])
                        {
                            c = true;
                        }
                    }

                    if (c)
                    {
                        ml.PrintColor(ConsoleColor.Magenta, "You have already entered: " + word);
                    }

                    for (int i = 0; i < Arrayer.Length; i++)
                    {
                        ArrayerUp[i] = Arrayer[i].ToUpper();
                    }


                    foreach (string country in ArrayerUp)
                    {
                        if (wordUp == country)
                        {
                            if (!c)
                            {
                                score += 5;

                                for (int i = 0; i < compare.Length; i++)
                                {
                                    //if ((compare[i] == "" || compare[i] == null))
                                    if (string.IsNullOrEmpty(compare[i]))
                                    {
                                        compare[i] = wordUp;
                                        ml.PrintColor(ConsoleColor.Green, "CORRECT");
                                        ml.PrintColor(ConsoleColor.Yellow, word + " is in " + namer +
                                                      "\n\n");
                                        break;
                                    }
                                }
                            }

                            det = true;
                        }
                    }

                    if (!det)
                    {
                        ml.PrintColor(ConsoleColor.Red, "INCORRECT");
                        ml.PrintColor(ConsoleColor.Yellow, word + " is not in " + namer + "\n\n");
                    }
                } while (true);

                Console.Clear();
                ml.PrintColor(ConsoleColor.Cyan, "\nYour Total Score is: " + score);
                ml.PrintColor(ConsoleColor.Cyan, "Enter any key to return to African Countries Game menu");
                Console.ReadKey();
                p.AfConGame();
            }
            catch (FormatException)
            {
                MethodLibrary ml = new MethodLibrary();
                Program       p  = new Program();
                ml.CatchFormat();
                p.AfricanCon();
            }
            catch
            {
                MethodLibrary ml = new MethodLibrary();
                Program       p  = new Program();
                ml.CatchAll();
                p.AfricanCon();
            }
        }   // opens the all African countries game
示例#6
0
        public void PracticeCountries()
        {
            try
            {
                MethodLibrary ml = new MethodLibrary();

                int det;
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Cyan;

                //ml.PrintColor(ConsoleColor.Magenta,"Welcome to the African countries game",resetFcolor:true,
                //returnFcolor:ConsoleColor.Cyan);

                Console.WriteLine("Welcome to the Practice African countries menu");
                Console.WriteLine("========================================================\n");
                Console.WriteLine("Enter the associated number to choose an option\n");
                Console.WriteLine("1. Learn all African countries");
                Console.WriteLine("2. Learn all North African countries");
                Console.WriteLine("3. Learn all East African countries");
                Console.WriteLine("4. Learn all West African countries");
                Console.WriteLine("5. Learn all South African countries");
                Console.WriteLine("6. Learn all Central African countries");
                Console.WriteLine("7. Return to Main Menu");

                det = Convert.ToInt32(Console.ReadLine());

                if (det > 7 || det == 0)
                {
                    Console.Clear();
                    ml.PrintColor(ConsoleColor.Red, "Only Numbers 1 through 7 are allowed as input");
                    ml.PrintColor(ConsoleColor.Magenta, "Press any key to return to the Menu ");
                    Console.ReadKey();
                    DisplayMenu();
                }

                string[] regionArr  = allCountries;
                string   regionName = "all the Countries in Africa";

                switch (det)
                {
                case 1:
                    regionArr  = allCountries;
                    regionName = "all the Countries in Africa";
                    break;

                case 2:
                    regionArr  = northAfrican;
                    regionName = "all the North African Countries in Africa";
                    break;

                case 3:
                    regionArr  = eastAfrican;
                    regionName = "all the East African Countries in Africa";
                    break;

                case 4:
                    regionArr  = westAfrican;
                    regionName = "all the West African Countries in Africa";
                    break;

                case 5:
                    regionArr  = southAfrican;
                    regionName = "all the South African Countries in Africa";
                    break;

                case 6:
                    regionArr  = centralAfrican;
                    regionName = "all the Central African Countries in Africa";
                    break;

                case 7:
                    DisplayMenu();
                    break;
                }

                if (det < 7)
                {
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\n\nThese are " + regionName);
                    Console.WriteLine("=====================================================\n\n");

                    for (int i = 0; i < regionArr.Length; i++)
                    {
                        ml.PrintColor(ConsoleColor.Cyan, i + ". " + regionArr[i]);
                    }

                    ml.PrintColor(ConsoleColor.Yellow, "\n\n press any key to return to the Menu");
                    Console.ReadKey();
                    PracticeCountries();
                }
            }
            catch (FormatException)
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchFormat();
                AfConGame();
            }
            catch
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchAll();
                AfConGame();
            }
        }
示例#7
0
        }  // Displays the main menu

        public void AfConGame()
        {
            try
            {
                MethodLibrary ml = new MethodLibrary();

                int det;
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Cyan;

                //PrintColor(ConsoleColor.Magenta,"Welcome to the African countries game",resetFcolor:true,
                //returnFcolor:ConsoleColor.Cyan);

                Console.WriteLine("Welcome to the African countries game");
                Console.WriteLine("=============================================\n");
                Console.WriteLine("Enter the associated number to choose an option\n");
                Console.WriteLine("1. Play all African countries");
                Console.WriteLine("2. Play all North African countries");
                Console.WriteLine("3. Play all East African countries");
                Console.WriteLine("4. Play all West African countries");
                Console.WriteLine("5. Play all South African countries");
                Console.WriteLine("6. Play all Central African countries");
                Console.WriteLine("7. Return to Menu");

                det = Convert.ToInt32(Console.ReadLine());

                if (det > 7 || det == 0)
                {
                    ml.IfState(7);
                    DisplayMenu();
                }

                switch (det)
                {
                case 1:
                    AfricanCon();
                    break;

                case 2:
                    NorthAfricanCon();
                    break;

                case 3:
                    EastAfricanCon();
                    break;

                case 4:
                    WestAfricanCon();
                    break;

                case 5:
                    SouthAfricanCon();
                    break;

                case 6:
                    CentralAfricanCon();
                    break;

                case 7:
                    DisplayMenu();
                    break;
                }
            }
            catch (FormatException)
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchFormat();
                AfConGame();
            }
            catch
            {
                MethodLibrary ml = new MethodLibrary();
                ml.CatchAll();
                AfConGame();
            }
        }   // starts the african countries game menu