这是一个关于C#控制台的程序,有点错误,请帮忙修改一下.谢谢

kn75897747 2009-03-20 07:45:34
using System.Timers;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;

namespace zy
{
class Program1
{


public static int n;
public static void Main(string[] args)
{
//int n;
Console.WriteLine("MAIN MENU");
Console.WriteLine("1 初学者");
Console.WriteLine("2一般玩家");
Console.WriteLine("3 专家");
Console.WriteLine("请选择难度n(1,2,3)");
n = Convert.ToInt32(Console.ReadLine());
Program2 b = new Program2();

switch (n)
{
case 1:
b.Game1();
break;
default:
b.Test4();
break;
}
Console.ReadLine();
}

}

class Program2
{

string G, word;
int A;


public void Game1()
{
Console.Clear();
Program2 c = new Program2();

c.Test1();
c.Test2();
c.Test3();
c.Test4();

}

void Test1()
{

Program2 D = new Program2();
//Program3 e = new Program3();
int C, M,T;
C = 8;
M = 0;
T = 0;

Console.WriteLine("chances:{0} Marks:{1} Time Elapsed:{2}", C, M, T);
int returnval = D.Test3();
if (returnval == 1)
{
M += 1;
Console.Write(M);
}
if (returnval == 0)
{
M += 0;
C -= 1;
}

}
public void Test2()
{
string a;
StreamReader sr = new StreamReader(@"E:world1.txt");
string[] strs = sr.ReadToEnd().Split(new char[] { ' ', '\n', ',', '.' });
Random rd = new Random();

a = strs[rd.Next(0, strs.Length - 1)];
// Console.WriteLine(strs[rd.Next(0, strs.Length - 1)]);
// Console.ReadLine();

string word = strs[rd.Next(0, strs.Length - 1)];
int hen = 3;//横线个数
Random r = new Random();
for (int i = 0; i < hen; i++)
{
int k = r.Next(0, word.Length - 1);
word = word.Remove(k, 1);
word = word.Insert(k, "_");
}
Console.WriteLine(word);
Console.ReadLine();

}
public int Test3()
{
//string G;
Console.WriteLine("Guss:{0}", G);
if (word == G)
{
Console.WriteLine("回答正确");
return 0;
}
else
{
Console.WriteLine("回答错误");
return 0;
}

}
public void Test4()
{
//int A;
//Console.WriteLine("Total Characters:{0} ",A);
//A=a.Length;
Console.WriteLine("处理异常");
}
}

class Program3
{
static int counter = 1;

public static void Test()
{
Timer T = new Timer(1000);
T.Elapsed += new ElapsedEventHandler(WriteChar);
T.Start();

Console.ReadKey(true);
}

public static void WriteChar(object source, ElapsedEventArgs e)
{
Console.Clear();

if (counter == 0)
{
Console.Write("游戏结束");
}
else
{
Console.Write(counter++);
}
}
}

}




这其实是个猜单词的游戏
期中有些步骤还没完善
主要是 怎么使 Time Elapsed:{2}", 在游戏开始的时候出现正计时
还有 猜对了 单词 那个 Marks:{1} 怎么更新分数
我刚刚学C# 还有好多知识没有学会
还请帮忙
因为没有那么多分 所以无法给分
还请谅解
谢谢



...全文
83 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧