using System;
namespace Example49
{
///
/// Summary description for Class1.
///
class Class1
{
public enum Coin { heads, tails }
private static Random r = new Random();
public static Coin yourGuess()
{
Console.Write("What's your guess? (heads or tails): ");
return Console.ReadLine().ToLower().Trim() == "heads" ? Coin.heads : Coin.tails;
}
public static Coin computerToss()
{
return r.Next(2) == 0 ? Coin.heads : Coin.tails;
}
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
do
{
if (yourGuess() == computerToss())
{
Console.WriteLine("You win!");
}
else
{
Console.WriteLine("Computer wins!");
}
Console.Write("Another game? (y or n): ");
} while (Console.ReadLine().ToLower().Trim() == "y");
}
}
}