Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C#-----Create a game similar to Hangman named GuessAWord in which a player gu

ID: 3679431 • Letter: I

Question

In C#-----Create a game similar to Hangman named GuessAWord in which a player guesses letters
to try to replicate a hidden word. Store at least eight words in an array, and randomly
select one to be the hidden word. Initially,display the hidden word using asterisks to represent each letter. Allow the user to guess
letters to replace the asterisks in the hidden word until the user completes the entire
word. If the user guesses a letter that is not in the hidden word, display an appropriate
message. If the user guesses a letter that appears multiple times in the hidden word, make
sure that each correct letter is placed. If you create the GUI version of
the game, you might want to include a Start button that selects the random word and
performs other startup tasks before you reveal the game interface. After the startup tasks
are complete, you can remove the Start button from the form.

Modification and clarifications:
---Create a GUI (Windows Form) version
---Use a fixed-width font for displaying a word being guessed.
---Pay attention to turning on and off visibility of different user interface elements when needed.
---Additionally, display in red the current total number of unsuccessful guesses, including repeating ones (just
ignore repeating correct guesses).
---Clear the input textbox as part of input processing
---When the word is guessed correctly:
1. stop taking more guesses for the current word;
2. display congratulation;
3. do not dismiss the word and the number of wrong guesses;
4. offer a new round of the game.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GuessAWord
{
public partial class Form1 : Form
{
String s;
int wr;
public Form1()
{
wr = 0;
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
String[] w={"one","two","three","four","five","six","seven","eight"};
Random r = new Random();
int i = r.Next(0, 7);
s = w[i];
button1.Visible = false;

}

private void button2_Click(object sender, EventArgs e)
{
  
if (s.Equals(textBox1.Text))
{
label1.Text = "Congratulations";

}
else
{

wr++;
label1.Text = "Guess is worng!!! Pl. try again";
label2.Text = wr.ToString();
textBox1.Clear();

}


}

private void textchange(object sender, EventArgs e)
{

}
}
}