-1
嘿家伙即时制作游戏,以帮助我学习决赛。它基本上是闪存卡。我希望程序通过随机选择一个打印出我的问题和答案。事情是我不希望他相同的随机数被挑选两次。我如何确保相同的号码不被挑选两次,直到我没有问题?我试图将每个随机数存储在黑名单中,以便在程序打印之前检查数字是否已经存在。如何让我的程序继续?
import java.util.ArrayList;
import java.util.Random;
public class Games {
static ArrayList<Integer> blacklist = new ArrayList<Integer>();
static int number;
static String[][] yes = {{"Apostolic Orgin", "Comes form the apostles"},
{"Biblical inerrancy", "the doctrine that the books are free from error reading the truth"},
{"Divine Inspiration", "the assistance the holy spirit gave the authors or the bible so they could write"},
{"fundamentalist approach", "interpretation of the bible and christian doctrine based on the literal meaning og bible's word"}, {"pentateuch", "first 5 books of old testament"}};
public static void main(String[] args) {
Printer(pickQuestion(), pickAnswer());
}
public static int RandomNumber(int i) {
int c;
Random r = new Random();
c = r.nextInt(i);
return c;
}
public static void Printer(String question, String answer) {
System.out.println("Question: " + question);
System.out.println("Answer: " + answer);
}
public static String pickQuestion() {
number = RandomNumber(yes.length);
return yes[number][0];
}
public static String pickAnswer() {
return yes[number][1];
}
}