// TODO 用于判断题目答案是否正确的函数 private void Charge(int i) { if (type == 0) { if (Answer[i] .getText() .equals(wordLib.getMean(dictionary.Tree.getWordIndex(NewWord.get(index))))) { RightAnswer.setText("恭喜回答正确"); ChangeCard("p2"); } else { RightAnswer.setText( "可惜了回答错误,继续努力。正确答案为" + wordLib.getMean(dictionary.Tree.getWordIndex(NewWord.get(index)))); ChangeCard("p2"); } } else { if (Answer[i].getText().equals(NewWord.get(index))) { RightAnswer.setText("恭喜回答正确"); ChangeCard("p2"); } else { RightAnswer.setText("可惜了回答错误,继续努力。正确答案为" + NewWord.get(index)); ChangeCard("p2"); } } }
// 用于把所有生词添加到List中的函数 private static void AddWordToList() { NewwordsList.setFont(dictionary.myFont); String[] newword = new String[NewWord.size()]; for (int i = 0; i < NewWord.size(); i++) { String blank = ""; for (int j = 0; j < 20 - NewWord.get(i).length(); j++) { blank = blank + " "; } newword[i] = NewWord.get(i) + blank + wordLib.getMean(dictionary.Tree.getWordIndex(NewWord.get(i))); } NewwordsList.setListData(newword); NewWordListPanel.setViewportView(null); NewWordListPanel.setViewportView(NewwordsList); }
// TODO 复制文件 //用于生成下一个spell题目的函数 private void NextSpellQuestion() { ChangeCard("p3"); boolean flag = false; for (int i = 0; i < NewWord.size(); i++) { if (!mark[i]) flag = true; } if (!flag) { for (int i = 0; i < NewWord.size(); i++) { mark[i] = false; } } Random random = new Random(); while (true) { index = random.nextInt(NewWord.size()); if (!mark[index]) { mark[index] = true; break; } } Questionmean.setText(wordLib.getMean(dictionary.Tree.getWordIndex(NewWord.get(index)))); WordTextFile.setText(""); WordTextFile.requestFocus(); }
// TODO 复制文件 //用于产生下一个题目的函数 private void NewPractice() { ChangeCard("p1"); boolean flag = false; for (int i = 0; i < NewWord.size(); i++) { if (!mark[i]) flag = true; } if (!flag) { for (int i = 0; i < NewWord.size(); i++) { mark[i] = false; } } Random random = new Random(); while (true) { index = random.nextInt(NewWord.size()); if (!mark[index]) { mark[index] = true; break; } } type = random.nextInt(2); if (type == 0) { Subject.setText(NewWord.get(index)); boolean[] num = new boolean[4]; for (int i = 0; i < 4; i++) { num[i] = false; } int index1 = random.nextInt(4); Answer[index1].setText(wordLib.getMean(dictionary.Tree.getWordIndex(NewWord.get(index)))); num[index1] = true; for (int i = 0; i < 3; i++) { while (true) { index2 = random.nextInt(4); if (!num[index2]) break; } if (NewWord.size() < 10) { Answer[index2].setText( wordLib.getMean( dictionary.Tree.getWordIndex(wordLib.getWord(random.nextInt(15000))))); } else { Answer[index2].setText( wordLib.getMean( dictionary.Tree.getWordIndex(wordLib.getWord(random.nextInt(NewWord.size()))))); } num[index2] = true; } } else { Subject.setText(wordLib.getMean(dictionary.Tree.getWordIndex(NewWord.get(index)))); boolean[] num = new boolean[4]; for (int i = 0; i < 4; i++) { num[i] = false; } index1 = random.nextInt(4); Answer[index1].setText(NewWord.get(index)); num[index1] = true; for (int i = 0; i < 3; i++) { int index2 = 0; while (true) { index2 = random.nextInt(4); if (!num[index2]) break; } if (NewWord.size() < 10) { Answer[index2].setText(wordLib.getWord(random.nextInt(15000))); } else { Answer[index2].setText(NewWord.get(random.nextInt(NewWord.size()))); } num[index2] = true; } } }