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.

New Topic/Question
Reply



MultiQuote




|