Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C#: Hello, I am having trouble turning code from a console application to a windows form application and then hooking it up to a form.

C#: Hello, I am having trouble turning code from a console application to a windows form application and then hooking it up to a form. So I am making a word scramble game and have coded the scrambler using arrays that are storing the words and am now confused on how to get it to work. In one class I want to store the words and then when a user hits a radio button (labeled easy, medium, or hard) then that corresponding level will start to output one word of the array at a time to the form. Once the user gets the word correct it moves to another word until there are no more words on that level or the user selects another radio button.

Here is what my form looks like right now:

image text in transcribed

Here is my code so far:

class Program { //Main method static void Main(string[] args) { // String arrays to store original words and scrambled words // String for easy words string[] easy = { "cat", "dog", "boy", "ice", "mad", "nut", "old", "ram", "cup", "car", "kid", "toy", "bin", "bit", "sun", "one", "two", "six", "ten", "act", "ace", "arc", "box", "bun", "bid", "bee", "run", "see", "sea", "lip" }; string[] easyScramble = new string[easy.Length]; // Object creation var c = new Converter(); // Call converter class method to scramble each word in the array // and store into another array for (int i = 0; i

// String for the medium words string[] medium = { "nose", "easy", "girl", "grew", "nice", "tree", "then", "than", "this", "that", "bird", "grow", "game", "hard", "sell", "fall", "more", "gift", "jump", "snow", "rain", "fish", "able", "also", "acid", "area", "math", "four", "five", "nine" }; string[] mediumScramble = new string[medium.Length]; // Object creation var a = new Converter(); // Call converter class method to scramble each word in the array // and store into another array for (int i = 0; i

// String for hard words string[] hard = { "three", "spell", "grave", "stone", "truck", "apple", "craft", "horse", "start", "train", "paint", "agree", "again", "alert", "block", "cover", "daily", "cream", "delay", "earth", "faith", "lunch", "magic", "rapid", "sleep", "title", "upper", "worse", "woman", "virus", "water"}; string[] hardScramble = new string[hard.Length]; // Object creation var b = new Converter(); // Call converter class method to scramble each word in the array // and store into another array for (int i = 0; i

Console.ReadKey(); } }

and my main class:

class Converter { //Convertor function public string ScrambleWord(string word) { //Array to take each charcters in the string to scramble char[] scramble = new char[word.Length]; //Randomly select the character Random rand = new Random(10000); //Variable to get the scramble array index int index = 0; //Loop to check until entire word while (word.Length > 0) { // Get a random number between 0 and the length of the word. int next = rand.Next(0, word.Length - 1); // Take the character from the random position and add to our char array. scramble[index] = word[next]; // Remove the character from the word. //Substring method in string to generate next word word = word.Substring(0, next) + word.Substring(next + 1); ++index; } //Return the scrambled word return new String(scramble); } }

Thank you for any help you can provide.

Scrambler - O X Difficulty Easy O Medium O Hard Submit Exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions