Hang man code

  • Thread starter Thread starter Zoha.Jan
  • Start date Start date
Z

Zoha.Jan

Guest
I am very new to coding and I am trying to do a <g class="gr_ gr_105 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" data-gr-id="105" id="105">hang man</g> code. this is what I have so far but I don't know how to code that the user has three lives. Very simple coding would be nice <g class="gr_ gr_432 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" data-gr-id="432" id="432">so <g class="gr_ gr_443 gr-alert gr_tiny gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling multiReplace" data-gr-id="443" id="443">i</g></g> can understand it


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to <g class="gr_ gr_26 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="26" id="26">hangan</g>! <g class="gr_ gr_27 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="27" id="27">Lets</g> begin. ");

string[] arrayofwords = { "blue", "black", "yellow", "orange", "green", "purple", "red", "pink", "maroon", "gold" };
Random ran = new Random();
string mywords = arrayofwords[ran.Next(0, arrayofwords.Length)];
Console.WriteLine("Category is colours");
char[] guess = new char[mywords.Length];
for (int p = 0; p < mywords.Length; p++)
guess[p] = '*';
while (true)
{
Console.WriteLine("please write your guess");
char Playerguess = char.Parse(Console.ReadLine());

for (int j = 0; j < mywords.Length; j++)

{

if (Playerguess == mywords[j])
guess[j] = mywords[j];

else
{
Console.WriteLine("you guessed wrong");
}
}

Console.WriteLine(guess);


}




}
}

}

Continue reading...
 
Back
Top