atultiwari

GamePlay.java

Jul 16th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.76 KB | None | 0 0
  1. //-------- GamePlay.java ------- //
  2. package com.atultiwari.medicalquiz;
  3.  
  4. import java.util.ArrayList;
  5. import java.util.List;
  6.  
  7. /**
  8.  * @author robert.hinds
  9.  *
  10.  * This class represents the current game being played
  11.  * tracks the score and player details
  12.  *
  13.  */
  14. public class GamePlay {
  15.    
  16.     private int numRounds;
  17.     private int difficulty;
  18.     private String playerName;
  19.     private int right;
  20.     private int wrong;
  21.     private int round;
  22.    
  23.     private List<Question> questions = new ArrayList<Question>();
  24.    
  25.     /**
  26.      * @return the playerName
  27.      */
  28.     public String getPlayerName() {
  29.         return playerName;
  30.     }
  31.     /**
  32.      * @param playerName the playerName to set
  33.      */
  34.     public void setPlayerName(String playerName) {
  35.         this.playerName = playerName;
  36.     }
  37.     /**
  38.      * @return the right
  39.      */
  40.     public int getRight() {
  41.         return right;
  42.     }
  43.     /**
  44.      * @param right the right to set
  45.      */
  46.     public void setRight(int right) {
  47.         this.right = right;
  48.     }
  49.     /**
  50.      * @return the wrong
  51.      */
  52.     public int getWrong() {
  53.         return wrong;
  54.     }
  55.     /**
  56.      * @param wrong the wrong to set
  57.      */
  58.     public void setWrong(int wrong) {
  59.         this.wrong = wrong;
  60.     }
  61.     /**
  62.      * @return the round
  63.      */
  64.     public int getRound() {
  65.         return round;
  66.     }
  67.     /**
  68.      * @param round the round to set
  69.      */
  70.     public void setRound(int round) {
  71.         this.round = round;
  72.     }
  73.     /**
  74.      * @param difficulty the difficulty to set
  75.      */
  76.     public void setDifficulty(int difficulty) {
  77.         this.difficulty = difficulty;
  78.     }
  79.     /**
  80.      * @return the difficulty
  81.      */
  82.     public int getDifficulty() {
  83.         return difficulty;
  84.     }
  85.     /**
  86.      * @param questions the questions to set
  87.      */
  88.     public void setQuestions(List<Question> questions) {
  89.         this.questions = questions;
  90.     }
  91.    
  92.     /**
  93.      * @param q the question to add
  94.      */
  95.     public void addQuestions(Question q) {
  96.         this.questions.add(q);
  97.     }
  98.    
  99.     /**
  100.      * @return the questions
  101.      */
  102.     public List<Question> getQuestions() {
  103.         return questions;
  104.     }
  105.    
  106.    
  107.     public Question getNextQuestion(){
  108.        
  109.         //get the question
  110.         Question next = questions.get(this.getRound());
  111.         //update the round number to the next round
  112.         this.setRound(this.getRound()+1);
  113.         return next;
  114.     }
  115.    
  116.     /**
  117.      * method to increment the number of correct answers this game
  118.      */
  119.     public void incrementRightAnswers(){
  120.         right ++;
  121.     }
  122.    
  123.     /**
  124.      * method to increment the number of incorrect answers this game
  125.      */
  126.     public void incrementWrongAnswers(){
  127.         wrong ++;
  128.     }
  129.     /**
  130.      * @param numRounds the numRounds to set
  131.      */
  132.     public void setNumRounds(int numRounds) {
  133.         this.numRounds = numRounds;
  134.     }
  135.     /**
  136.      * @return the numRounds
  137.      */
  138.     public int getNumRounds() {
  139.         return numRounds;
  140.     }
  141.    
  142.     /**
  143.      * method that checks if the game is over
  144.      * @return boolean
  145.      */
  146.     public boolean isGameOver(){
  147.         return (getRound() >= getNumRounds());
  148.     }
  149.  
  150.  
  151. }
Advertisement
Add Comment
Please, Sign In to add comment