我有一个要求用户回答问题的控制台应用程序,分数显示在屏幕的右上角,我希望分数在用户给出正确答案时自动更新。
public void L1Timer()
{
Console.Clear();
int ch = 0, score = 0;
Console.Write("Chances : " + ch);
Console.CursorLeft = 40;
Console.Write("Marks : " + score);
for (int time = 0; time <= 100000; time++)
{
Console.SetCursorPosition(65, 0);
Console.Write("Time Elapsed : " + time + " Secs");
Console.CursorLeft = 40;
Thread.Sleep(1000);
}
}
public void Level1()
{
Console.WriteLine("\n\n");
Console.CursorLeft = 40;
Console.WriteLine("C _ _ E _ _ _ T _ _ N");
Console.WriteLine("\n\n");
int tot = 0;
while (tot != 70)
{
Console.Write("Guess : ");
string gues = Console.ReadLine();
if ((gues == "E") || (gues == "L") || (gues == "B") || (gues == "R"))
{
tot += 10;
}
}
}
static void Main(string[] args)
{
VocEnhancer VE = new VocEnhancer();
Thread T1 = new Thread(new ThreadStart (VE.L1Timer));
Console.WriteLine("\n\n\n\n\n");
Thread T2 = new Thread(new ThreadStart(VE.Level1));
T1.Start();
T2.Start();
}
这是我的代码...我不知道要添加什么来自动更新分数。