Android Open Source - Game-of-thrones-trivia Question Collection






From Project

Back to project page Game-of-thrones-trivia.

License

The source code is released under:

MIT License

If you think the Android project Game-of-thrones-trivia listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.GameOfThrones.Trivia.core;
//ww w. java 2 s  .  c om
import java.io.Serializable;
import java.util.ArrayList;

import com.GameOfThrones.Trivia.util.GeneralAlgorithms;

public class QuestionCollection implements SimpleIterator<Question>,
    Serializable {

  ArrayList<Question> questions;

  /**
   * 
   */
  private static final long serialVersionUID = -8666055296634378061L;

  int currentPos;

  public QuestionCollection(ArrayList<Question> questions) {
    this.questions = questions;
    beforeFirst();
  }

  /**
   * Shuffles the order questionView order
   */
  public void shuffle() {
    Object[] temp = GeneralAlgorithms.shuffleArray(questions.toArray());
    questions.clear();
    for (Object o : temp) {
      questions.add((Question) o);
    }
    beforeFirst();
  }

  public void beforeFirst() {
    currentPos = -1;
  }

  public void next() {
    currentPos++;
  }

  public Question current() {
    return questions.get(currentPos);
  }

  public boolean isDone() {
    return currentPos >= questions.size();
  }

  /**
   * Keeps questions only whose ids match any in the keepIds
   * QuestionCollection.
   * 
   * @param keepsIds
   *            - list of questions ids
   */
  public void keepOnly(ArrayList<Integer> keepsIds) {
    ArrayList<Question> temp = new ArrayList<Question>();
    for (Question question : questions) {
      if (keepsIds.contains(question.getId())) {
        temp.add(question);
      }
    }
    questions = temp;
  }
}




Java Source Code List

com.GameOfThrones.Trivia.core.CharacterToQuestionsMap.java
com.GameOfThrones.Trivia.core.GameCharacter.java
com.GameOfThrones.Trivia.core.HighScore.java
com.GameOfThrones.Trivia.core.OutOfQuestionsException.java
com.GameOfThrones.Trivia.core.QuestionCollection.java
com.GameOfThrones.Trivia.core.Question.java
com.GameOfThrones.Trivia.core.Session.java
com.GameOfThrones.Trivia.core.SimpleIterator.java
com.GameOfThrones.Trivia.core.TriviaGame.java
com.GameOfThrones.Trivia.data.HighScorePrefs.java
com.GameOfThrones.Trivia.data.RequestWebService.java
com.GameOfThrones.Trivia.data.StringsXMLFileData.java
com.GameOfThrones.Trivia.ui.AboutActivity.java
com.GameOfThrones.Trivia.ui.DynamicBackgroundActivity.java
com.GameOfThrones.Trivia.ui.GameActivity.java
com.GameOfThrones.Trivia.ui.HighScoreActivity.java
com.GameOfThrones.Trivia.ui.MainMenuActivity.java
com.GameOfThrones.Trivia.ui.ResultsActivity.java
com.GameOfThrones.Trivia.ui.TriviaSelectionActivity.java
com.GameOfThrones.Trivia.ui.music.MusicService.java
com.GameOfThrones.Trivia.util.GeneralAlgorithms.java
com.Spartacus.TriviaTest.TriviaMenuActivityTest.java
com.Spartacus.Trivia.utilTest.GeneralAlgorithmsTest.java