Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. package connect4.model;
  2.  
  3. /**
  4. * This is the class Player. Here you can get the information if the player is a
  5. * machine or a human and other properties of the players of the game.
  6. */
  7. public class Player {
  8.  
  9. /**
  10. * Number of the groups of 2 tokens.
  11. */
  12. private int groupsOfTwo;
  13.  
  14. /**
  15. * Number of the groups of 3 tokens.
  16. */
  17. private int groupsOfThree;
  18.  
  19. /**
  20. * Number of the goups of 4 tokens.
  21. */
  22. private int groupsOfFour;
  23.  
  24. /**
  25. * Quality of the player if it's a machine or human player.
  26. */
  27. boolean isHuman = true;
  28.  
  29. /**
  30. * Used sign of the player.('X' if human player and 'O' if machine.)
  31. */
  32. private String usedSign = "";
  33.  
  34. /**
  35. * Constructor of the class Player.
  36. *
  37. * @param playerIsHuman
  38. * true if player is human and false if player is machine.
  39. */
  40. public Player(boolean playerIsHuman) {
  41. isHuman = playerIsHuman;
  42. if (isHuman) {
  43. usedSign = "X";
  44. } else {
  45. usedSign = "O";
  46. }
  47. groupsOfTwo = 0;
  48. groupsOfThree = 0;
  49. groupsOfFour = 0;
  50. }
  51.  
  52. /**
  53. * Method to get quality isHuman of the player.
  54. *
  55. * @return isHuman true if player is human and false if machine.
  56. */
  57. public boolean getIsHuman() {
  58. return isHuman;
  59. }
  60.  
  61. /**
  62. * Method to get used sign of the player.
  63. *
  64. * @return usedSign 'X' if it's an human player and 'O' if it's a machine.
  65. */
  66. public String getSign() {
  67. return usedSign;
  68. }
  69.  
  70. /**
  71. * Method to change player..
  72. *
  73. * @param playerIsHuman
  74. * true if it is an human player and false if it's a machine.
  75. */
  76. public void changePlayer(boolean playerIsHuman) {
  77. isHuman = playerIsHuman;
  78. }
  79.  
  80. /**
  81. * Method to count groups of 2 tokens.
  82. *
  83. * @param i
  84. * number of groups of 2 tokens.
  85. */
  86. public void setGroupOfTwoCounter(int i) {
  87. groupsOfTwo = i;
  88. }
  89.  
  90. /**
  91. * Method to count groups of 3 tokens.
  92. *
  93. * @param i
  94. * number of groups of 3 tokens.
  95. */
  96. public void setGroupOfThreeCounter(int i) {
  97. groupsOfThree = i;
  98. }
  99.  
  100. /**
  101. * Method to count groups of 4 tokens.
  102. *
  103. * @param i
  104. * number of groups of 4 tokens.
  105. */
  106. public void setGroupOfFourCounter(int i) {
  107. groupsOfFour = i;
  108. }
  109.  
  110. /**
  111. * Method to get number of groups of 4 tokens.
  112. *
  113. * @return number of groups of 4 tokens.
  114. */
  115. public int getGroupOfFourCounter() {
  116. return groupsOfFour;
  117. }
  118.  
  119. /**
  120. * Method to get number of groups of 3 tokens.
  121. *
  122. * @return number of groups of 3 tokens.
  123. */
  124. public int getGroupOfThreeCounter() {
  125. return groupsOfThree;
  126. }
  127.  
  128. /**
  129. * Method to get number of groups of 2 tokens.
  130. *
  131. * @return number of groups of 2 tokens.
  132. */
  133. public int getGroupOfTwoCounter() {
  134. return groupsOfTwo;
  135. }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement