Assignment#02 (C#-116)
Assignment#02 (C#-116)
Assignment#02
11/17/2022
BSCS 5th A
Ali Hassan
Reg: uw-20m-cs-bs-116
HANGMAN GAME
Code:
namespace Assignment2
{
public partial class Form1 : Form
{
int chances = 7;
int current_index = 0;
public Form1()
{
InitializeComponent();
}
{
if (current_index > textBox1.Text.Length - 1)
break;
if (textBox1.Text[current_index] == word[current_index])
}
else
{
chances--;
switch (chances)
{
case 6:
{
pictureBox1.Visible = true;
break;
}
case 5:
{
pictureBox3.Visible = true;
break;
}
case 4:
{
pictureBox4.Visible = true;
break;
}
case 3:
{
pictureBox2.Visible = true;
break;
}
case 2:
{
pictureBox6.Visible = true;
break;
}
case 1:
{
pictureBox5.Visible = true;
break;
}
}
current_index++;
}
}
}
Screenshot:
Firstly run:
THANK YOU…..!!!
University of Wah
Department of Computer Science