public void randomArray() { int RandomList = Arrays.asList(RandomNumArray); for(int i = 0; i < questionAmount; i ++) { int num = RandomNum(questionAmount); System.out.println(num); int result = RandomList.contains(quesitonAmount); } }
public void randomArray() { int RandomList = Arrays.asList(RandomNumArray); for(int i = 0; i < questionAmount; i ++) { int num = RandomNum(questionAmount); System.out.println(num); int result = RandomList.contains(quesitonAmount); } }
int questionAmount; final int ARRAY_SIZE = 10; int[] randomNumArray = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; String[] questionArray = {"Accused money launderers tried to move $1 million in cooler bags"} /** * Act - do whatever the Game wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { // Add your action code here. menu(); } public void menu() { Object[] options = {"News Quiz Game", "Fake Count Game"}; int i = JOptionPane.showOptionDialog(null, "What game mode would you like to play","Quiz Game", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[0]); if (i == 1) { System.out.println("you have picked Fake games") ; FakeGames(); } if (i == 0) { JOptionPane.showMessageDialog(null, "You have picked News Quiz Game"); NewsQuiz(); } } public void FakeGames() { QuestionAmount(); randomArray(); } public void NewsQuiz() { QuestionAmount(); } public void QuestionAmount() { String str; while (true) { str = JOptionPane.showInputDialog("input the amount of question you went to try between 2-5"); questionAmount = Integer.parseInt(str); if (questionAmount <= 10 && questionAmount >=3) { break; } } } public int RandomNum(int num) { int RandNum = Greenfoot.getRandomNumber(num); //System.out.println(RandNum); return RandNum; } public void randomArray() { int i, num; for( i= 0; i < questionAmount; i ++) { num = RandomNum(questionAmount); //System.out.println(num); boolean duplicate = Arrays.asList(randomNumArray).contains(num); if(duplicate == false) { System.out.println("no"); randomNumArray[i] = num ; } } for(i = 0; i < questionAmount; i ++) System.out.println(randomNumArray[i]); } }
for (int i=0; i<ARRAY_SIZE; i++) randomNumArray[i] = i;
int[] randonNumArray = new int[ARRAY_SIZE];
public void shuffleArray() { List <Integer> intList = Arrays.asList(randomNumArray); Collections.shuffle(intList); intList.toArray(randomNumArray); for(int i = 0; i < questionAmount; i ++) System.out.println(randomNumArray[i]); }