Advertisement
Boucherwayne78

Untitled

Feb 28th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package rollem;
  7.  
  8. /**
  9.  *
  10.  * @author wayne
  11.  */
  12. public class Player
  13. {
  14.     private int turnScore = 0;
  15.     private int gameScore = 0;
  16.     private int d1;
  17.     private int d2;
  18.    
  19.    
  20.     void Player()
  21.     {
  22.        
  23.     }
  24.  
  25.     int rollDie(DieLabel die1, DieLabel die2)
  26.     {
  27.         d1 = die1.rollDie();
  28.         d2 = die2.rollDie();
  29.         if (isTurnScoreLost())
  30.         {
  31.             if (isGameScoreLost())
  32.                 return 0;
  33.             return 0;
  34.         }
  35.         turnScore += d1 + d2;
  36.         return d1 + d2;
  37.     }
  38.  
  39.     boolean isTurnScoreLost()
  40.     {
  41.         if (d1 == 1 || d2 == 1)
  42.         {
  43.             turnScore = 0;
  44.             return true;
  45.         }
  46.         else return false;
  47.     }
  48.  
  49.     boolean isGameScoreLost()
  50.     {
  51.         if (d1 == 1 && d2 == 1)
  52.         {
  53.             reset();
  54.             return true;
  55.         }
  56.         else return false;
  57.     }
  58.  
  59.     boolean hasWon()
  60.     {
  61.         if (gameScore > 100 || turnScore > 100)
  62.             return true;
  63.         else return false;
  64.     }
  65.  
  66.     boolean addTurnScoreToGameScore()
  67.     {
  68.         if (isTurnScoreLost())
  69.             return false;
  70.         if (isGameScoreLost())
  71.             return false;
  72.         gameScore += turnScore;
  73.         turnScore = 0;
  74.         return true;
  75.     }
  76.  
  77.     int getTurnScore()
  78.     {
  79.         return turnScore;
  80.     }
  81.  
  82.     int getGameScore()
  83.     {
  84.         return gameScore;
  85.     }
  86.  
  87.     void reset()
  88.     {
  89.         turnScore = 0;
  90.         gameScore = 0;
  91.     }
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement