/******************************************************************************
Code, Compile, Run and Debug C# program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
static void Main(string[] args)
// Create a GUI for the fighting game
// Code to create the GUI for the fighting game
// Initialize player and enemy health
while (playerHealth > 0 && enemyHealth > 0)
Console.WriteLine("Player's turn:");
Console.WriteLine("1. Attack");
Console.WriteLine("2. Defend");
Console.WriteLine("3. Quit");
int choice = Convert.ToInt32(Console.ReadLine());
int playerDamage = new Random().Next(10, 21);
enemyHealth -= playerDamage;
Console.WriteLine("Player attacked and dealt {0} damage to the enemy.", playerDamage);
// Player defends against enemy attack
int playerDefense = new Random().Next(5, 11);
playerHealth += playerDefense;
Console.WriteLine("Player defended and restored {0} health.", playerDefense);
Console.WriteLine("Quitting the game...");
Console.WriteLine("Invalid choice. Please try again.");
// Check if enemy is defeated
Console.WriteLine("Player wins!");
Console.WriteLine("Enemy's turn:");
int enemyDamage = new Random().Next(10, 21);
playerHealth -= enemyDamage;
Console.WriteLine("Enemy attacked and dealt {0} damage to the player.", enemyDamage);
// Check if player is defeated
Console.WriteLine("Enemy wins!");
Console.WriteLine("Player Health: {0}", playerHealth);
Console.WriteLine("Enemy Health: {0}", enemyHealth);
Console.WriteLine("Game Over");