1 Replies - 125 Views - Last Post: 04 February 2012 - 03:37 AM Rate Topic: -----

Topic Sponsor:

#1 slickrick  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-February 12

Jumble Game modifications

Posted 03 February 2012 - 10:40 PM

I have to create a game where a random array of letters is displayed and the user is prompted to guess what the letters spell out. After that it is supposed to re-jumble the next set of letters and have them guess again. By the error message I got I think i'm missing a big part of this but I'm not sure what it is...
class Jumble
    {

        //data members
        string[] arywords = { "TABLE", "CHAIR", "PLACEMAT", "PLATE", "FORK", "KNIFE" };
        string word;
        char[] displayWord;

        //constructor
        public Jumble() 
        {
            GenerateWord();
        }

        public string HiddenWord 
        {
            get { return word; }
        }
        //methods
        public string DisplayScramble()
        {
            string returnvalue = null;

            for (int i = 0; i < displayWord.Length; i++)
                returnvalue = returnvalue + displayWord[i];

            return returnvalue;

        }
        public void ScrambleWord()
        {
            int random;
            char temp;
            Random randObj = new Random();

            displayWord = new char[word.Length];  //initializing array

            for (int i = 0; i < word.Length; i++)
            {
                do
                    random = randObj.Next(word.Length);

                while (displayWord[random] != 0);

                temp = word[i];
                displayWord[random] = temp;
            }
        }
        private void GenerateWord()
        {
            int number;

            Random generator = new Random();

            number = generator.Next(arywords.Length);

            word = arywords[number];
        }

        public bool CompareGuess(string guess)
        {
            bool value;

            if (guess == word)
                value = true;
            else
                value = false;

            return value;

        }

    }


}

This post has been edited by Atli: 03 February 2012 - 11:09 PM
Reason for edit:: Added [code] tags.


Is This A Good Question/Topic? 0
  • +

Replies To: Jumble Game modifications

#2 RexGrammer  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 152
  • View blog
  • Posts: 664
  • Joined: 27-October 11

Re: Jumble Game modifications

Posted 04 February 2012 - 03:37 AM

And the error message is...?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1