Need ko rin po kasi gumamit ng StringBuilder at ArrayList.
C#:
using System;
using System.Text;
using System.Collections;
namespace GuessingGame
{
public class GuessingGame
{
public static void Main(string[] args)
{
bool OutOfAttempts = false;
Console.WriteLine("Simple Word-Guessing Game");
Console.WriteLine("Category: Korean Food");
StringBuilder word = new StringBuilder("Bibimbap");
string strword = word.ToString();
word[6] = '_'; word[0] = '_';
for(int index = 0; index < word.Length; index++)
{
Console.Write(word[index] + " ");
}
Console.WriteLine("\n");
for(int i = 0; i <= 3; i++)
{
Console.Write("Answer: ");
string answer = Console.ReadLine();
if (answer != word.ToString() && !OutOfAttempts)
{
if (answer == "a")
{
word.Remove(6, 1).Insert(6, 'a');
Console.WriteLine(word);
i++;
}
if (answer == "B" || answer == "b")
{
word.Remove(0, 1).Insert(0, 'B');
Console.WriteLine(word);
i++;
}
else if (i == 2)
{
Console.WriteLine("1 attempt left.");
continue;
}
else if (answer != strword && i == 3)
{
OutOfAttempts = true;
Console.WriteLine("Game Over.\nCorrect answer: " + strword);
}
}
else
{
Console.WriteLine("You win");
break;
}
}
}
}
}