daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Jan 13th, 2018 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             /*
  2.         *  Main method
  3.           */
  4.             TextView question;
  5.             private int qType = -1;
  6.         private int asked = 0;
  7.        private void QBegin() {
  8.         /*
  9.         * Gets a random question
  10.         */
  11.         question = (TextView) findViewById(R.id.question);
  12.          String[] types = { "Q1", "Q2", "Q3", "Q4", "Q5"};
  13.         Random random = new Random();
  14.           int qType = random.nextInt(5);
  15.            /*
  16.             * Passes that question to get specific answers
  17.            */
  18.         question.setText(types[qType]);
  19.          asked++;
  20.           getAnswers(qType);
  21.      }
  22.      public void shuffle(String input){
  23.         /*
  24.          * Unused shuffle method
  25.          */
  26.         List<Character> characters = new ArrayList<Character>();
  27.         for(char c:input.toCharArray()){
  28.             characters.add(c);
  29.         }
  30.          StringBuilder output = new StringBuilder(input.length());
  31.         while(characters.size()!=0){
  32.               int randPicker = (int)(Math.random()*characters.size());
  33.              output.append(characters.remove(randPicker));
  34.                              }
  35.          System.out.println(output.toString());
  36.            }
  37.          private int answer;
  38.     private void getAnswers(int Type) {
  39.         /*
  40.          * Gets random answers
  41.          */
  42.         Random random = new Random();
  43.         String answers_list[][] = {
  44.                 {"Answer 1-1", "Answer 2-1", "Answer 3-1", "Answer 4-1"},
  45.                 {"Answer 1-2", "Answer 2-2", "Answer 3-2", "Answer 4-2"},
  46.                 {"Answer 1-3", "Answer 2-3", "Answer 3-3", "Answer 4-3"},
  47.                 {"Answer 1-4", "Answer 2-4", "Answer 3-4", "Answer 4-4"},
  48.                 {"Answer 1-5", "Answer 2-5", "Answer 3-5", "Answer 4-5"}} ;
  49.         int answer_shuffle = random.nextInt(4);
  50.         /*
  51.          * Need help randomizing this
  52.          */
  53.         answer1.setText(answers_list[Type][0]);
  54.         answer2.setText(answers_list[Type][1]);
  55.         answer3.setText(answers_list[Type][2]);
  56.         answer4.setText(answers_list[Type][3]);
  57.        
  58.        
  59.         /*for (int rows = 0; rows < answers_list.length; rows++){
  60.         for (int cols = 0; cols < answers_list[rows].length; cols++){  
  61.           }
  62.             }*/
  63.         }
  64.  
  65. Basicly, how can I make these rows random?
  66.  
  67. *** Couldn't paste this...***
  68.  
  69. Instead of 0,1,2,3 , 0-3 in a random order, thanks.
  70.  
  71. Best regards
  72.  
  73. Alex
RAW Paste Data
Top