import java.io.*;
import java.util.Date;
class TQC110
{
String items[][];
long start, end;
Date d;
BufferedReader br;
public static void main(String args[])
{
int total = args.length;
int pairs = total / 2;
TQC110 tte;
if(total != 0 && pairs != 0)
{
String[][] tt = new String[pairs][2];
for(int k = 0; k < pairs ; k++)
{
tt[k][0] = args[k * 2];
tt[k][1] = args[k * 2 + 1];
}
tte = new TQC110(tt);
}
else
tte = new TQC110();
tte.start();
}
TQC110()
{
items = new String[5][2];
items[0][0] = "電腦";
items[0][1] = "Computer";
items[1][0] = "資料庫";
items[1][1] = "DataBase";
items[2][0] = "語法";
items[2][1] = "syntax";
items[3][0] = "學校";
items[3][1] = "School";
items[4][0] = "假期";
items[4][1] = "Vocation";
br = new BufferedReader(new InputStreamReader(System.in));
}
TQC110(String[][] it)
{
items = it;
br = new BufferedReader(new InputStreamReader(System.in));
}
void start()
{
String ans = "";
int correct = 0; // 計算答對題數
d = new Date();
start = d.getTime(); // 開始答題時間
System.out.println("請將題目的中文詞彙翻譯成英文單字!");
System.out.println("輸入英文單字答案後請按Enter鍵:\n");
for(int j = 0; j < items.length ; j++)
{
System.out.println("第" + (j + 1) + "題__ " + items[j][0]);
try
{
ans = br.readLine();
}
catch(IOException ioexception)
{
System.out.println(ioexception);
}
if(ans.equalsIgnoreCase(items[j][1]))
{
correct++;
System.out.println("答對了 !\n");
}
else
{
System.out.println("答錯了 !");
System.out.println("正確答案是" + items[j][1] + "\n");
}
}
d = new Date();
end = d.getTime(); // 結束答題時間
System.out.print("你使用了" + (end - start) / 1000L + "秒, 在");
System.out.println(items.length + "題中答對了" + correct + "題");
}
} |