Example #1
0
    //Ask the user what profession they want to use.

    public Professions GetProfession()
    {
        Console.Clear();

        //Objects for stats

        Warrior war  = new Warrior();
        Mage    mage = new Mage();
        Hunter  hun  = new Hunter();

        //Input and validation variables

        Professions chosenProf;

        string input   = "";
        bool   isValid = false;

        do
        {
            //Profession menu

            Console.WriteLine("-----------------------------------------");
            Console.WriteLine("|Which profession would you like to be?|");
            Console.WriteLine("|          (Type your selection)       |");
            Console.WriteLine("|                                      |");
            Console.WriteLine("|     - Warrior - HP= {0}, MP= {1}     |", war.GetHealth(), war.GetMag());
            Console.WriteLine("|     - Mage - HP= {0}, MP= {1}        |", mage.GetHealth(), mage.GetMag());
            Console.WriteLine("|     - Hunter -  HP= {0}, MP= {1}     |", hun.GetHealth(), hun.GetMag());
            Console.WriteLine("----------------------------------------");
            input = Console.ReadLine();

            input = input.ToLower();

            //Returns profession based on user input

            if (input[0] == 'w')
            {
                chosenProf = new Warrior();
                return(chosenProf);
            }
            else if (input[0] == 'm')
            {
                chosenProf = new Mage();
                return(chosenProf);
            }
            else if (input[0] == 'h')
            {
                chosenProf = new Hunter();
                return(chosenProf);
            }
            else
            {
                Console.WriteLine("This input is invalid, please try again!");
                return(null);
            }
        } while (!isValid);
    }