这是我为我的小弟弟制作的一个小程序,需要帮助记住动词。它此时想要做的是选择一个单词,然后作为用户输入相同的单词但在不同的时间输入例如生成运行的用户输入。我有一个二维数组中的所有单词,允许我比较它们。但是当我输入正确的答案时,它说我不正确。
package javaapplication1;
import java.util.Random;
import java.io.*;
public class JavaApplication1 {
public static void main(String[] args) throws IOException {
BufferedReader userInput =
new BufferedReader(new InputStreamReader(System.in));
String[][] myArray = { {"awake" , "awoke" , "awoken"},
{"be" , "was/were" , "been"},
{"beat" , "beat" , "beaten"},
{"become" , "became" , "become"},
{"begin" , "began" , "begun"},
{"bend" , "bent" , "bent"},
{"bet" , "bet" , "bet"},
{"bid" , "bid" , "bid"},
{"bite" , "bit" , "bitten"},
{"blow" , "blew" , "blown"},
{"break" , "broke" , "broken"},
{"bring" , "brought" , "brought"},
{"broadcast" , "broadcast" , "broadcast"},
{"build" , "built" , "built"},
{"burn" , "burned" , "burnt"},
{"buy" , "bought" , "bought"},
{"catch" , "caught" , "caught"},
{"choose" , "chose" , "chosen"},
{"come" , "came" , "come"},
{"cost" , "cost" , "cost"},
{"cut" , "cut" , "cut"},
{"dig" , "dug" , "dug"},
{"do" , "did" , "done"},
{"draw" , "drew" , "drawn"},
{"drive" , "drove" , "driven"},
{"drink" , "drank" , "drunk"},
{"eat" , "ate" , "eaten"},
{"fall" , "fell" , "fallen"},
{"feel" , "felt" , "felt"},
{"fight" , "fought" , "fought"},
{"find" , "found" , "found"},
{"fly" , "flew" , "flown"},
{"forget" , "forgot" , "forgotten"},
{"forgive" , "forgave" , "forgiven"},
{"freeze" , "froze" , "frozen"},
{"get" , "got" , "gotten"},
{"give" , "gave" , "given"},
{"go" , "went" , "gone"},
{"grow" , "grew" , "grown"},
{"hang" , "hung" , "hung"},
{"have" , "had" , "had"},
{"hear" , "heard" , "heard"},
{"hide" , "hid" , "hidden"},
{"hit" , "hit" , "hit"},
{"hold" , "held" , "held"},
{"hurt" , "hurt" , "hurt"},
{"keep" , "kept" , "kept"},
{"know" , "knew" , "known"},
{"lay" , "laid" , "laid"},
{"lead" , "led" , "led"},
{"leave" , "left" , "left"},
{"lend" , "lent" , "lent"},
{"let" , "let" , "let"},
{"lie" , "lay" , "lain"},
{"lose" , "lost" , "lost"},
{"make" , "made" , "made"},
{"mean" , "meant" , "meant"},
{"meet" , "met" , "met"},
{"pay" , "paid" , "paid"},
{"put" , "put" , "put"},
{"read" , "read" , "read"},
{"ride" , "rode" , "ridden"},
{"ring" , "rang" , "rung"},
{"rise" , "rose" , "risen"},
{"run" , "ran" , "run"},
{"say" , "said" , "said"},
{"see" , "saw" , "seen"},
{"sell" , "sold" , "sold"},
{"send" , "sent" , "sent"},
{"show" , "showed" , "shown"},
{"shut" , "shut" , "shut"},
{"sing" , "sang" , "sung"},
{"sit" , "sat" , "sat"},
{"sleep" , "slept" , "slept"},
{"speak" , "spoke" , "spoken"},
{"spend" , "spent" , "spent"},
{"stand" , "stood" , "stood"},
{"swim" , "swam" , "swum"},
{"take" , "took" , "taken"},
{"teach" , "taught" , "taught"},
{"tear" , "tore" , "torn"},
{"tell" , "told" , "told"},
{"think" , "thought" , "thought"},
{"throw" , "threw" , "thrown"},
{"understand" , "understood" , "understood"},
{"wake" , "woke" , "woken"},
{"wear" , "wore" , "worn"},
{"win" , "won" , "won"},
{"write" , "wrote" , "written"}};
Random rand1 = new Random();
int n = rand1.nextInt(88) ;
System.out.println(n);
System.out.println("The word is: " + myArray[n][0]);
System.out.println("Input your answer :");
String input = userInput.readLine();
if (input == myArray[n][1]) {
System.out.println("Well done");
}
else{
System.out.println("Better luck nex time");
System.out.println("The correct answer was : "
+ myArray[n][1]);
}
}
}