using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void PrintMenu()
{
Console.WriteLine("1、添加单词");
Console.WriteLine("2、背单词");
Console.WriteLine("3、退出系统");
Console.WriteLine("请输入菜单选项:");
}
static void Main(string[] args)
{
WordDictionary myDictionary = new WordDictionary();
while (true)
{
PrintMenu();
string command = Console.ReadLine();
if (command.Trim() == "1")
{
Word w =new Word();
Console.WriteLine("请输入单词英文和中文,中间用空格隔开");
string str = Console.ReadLine();
string[] a = str.Split(new char[] { ' ' },StringSplitOptions.RemoveEmptyEntries);
w.English = a[0];
w.Chinese = a[1];
myDictionary.AddWord(w);
}
else if (command.Trim() == "2")
{
int total = 0;
int right = 0;
for (; ; )
{
Word w = myDictionary.RandomWord();
Console.WriteLine(w.Chinese);
string eng = Console.ReadLine();
if (eng == "")
{
break;
}
if (eng == w.English)
{
right++;
}
total ++;
Console.WriteLine("呢的成绩是:"+(right *1.0/total *100).ToString());
}
}
else if (command.Trim() == "3")
{
break; //return;
}
else
{
Console.WriteLine("输入不正确");
}
}
}
}
}