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






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;
/*from ww w .j av  a  2 s.  c  om*/
import java.io.Serializable;
import java.util.Arrays;
/**
 * Represents a trivia questioView
 * @author andre
 *
 */
public class Question implements Serializable {
  /**
   * Used to identify object during Serialization processes
   */
  private static final long serialVersionUID = 7306464553446020989L;

  protected static int classId;
  protected String trivia;
  protected String[] answers;
  protected int correctAnswer;
  protected int id;

  public Question(String trivia, String[] answers, int correctAnswer) {
    this.trivia = trivia;
    this.answers = answers;
    this.correctAnswer = correctAnswer;
    id = classId++;
  }

  /**
   * @return the classId
   */
  public static int getClassId() {
    return classId;
  }

  /**
   * @param classId
   *            the classId to set
   */
  public static void setClassId(int classId) {
    Question.classId = classId;
  }

  /**
   * @return the id
   */
  public int getId() {
    return id;
  }

  /**
   * @param id
   *            the id to set
   */
  public void setId(int id) {
    this.id = id;
  }

  /**
   * 
   * @return trivia getter
   */
  public String getTrivia() {
    return trivia;
  }

  /***
   * 
   * @param trivia
   *            trivia setter
   */
  public void setTrivia(String question) {
    this.trivia = question;
  }

  /**
   * 
   * @return answers setter
   */
  public String[] getAnswers() {
    return answers;
  }

  /**
   * 
   * @param answers
   *            setter
   */
  public void setAnswers(String[] answers) {
    this.answers = answers;
  }

  /**
   * 
   * @return correctAnswer getter
   */
  public int getCorrectAnswer() {
    return correctAnswer;
  }

  /**
   * 
   * @param correctAnswer
   *            setter
   */
  public void setCorrectAnswer(int correctAnswer) {
    this.correctAnswer = correctAnswer;
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#toString()
   */
  @Override
  public String toString() {
    return "Question [trivia=" + trivia + ", answers="
        + Arrays.toString(answers) + ", correctAnswer=" + correctAnswer;
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    Question other = (Question) obj;
    if (id != other.id)
      return false;
    return true;
  }
}




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