Advertisement
Guest User

Untitled

a guest
May 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. class Main {
  2. public static void main(String[] args) {
  3. System.out.println("Hello world!");
  4. //maak een game object
  5. //run de game totdat het klaar is. (vol of winnende zet is gezet)
  6.  
  7.  
  8. }
  9. }
  10.  
  11.  
  12.  
  13. class VORGame{
  14.  
  15. int[][] bord;
  16.  
  17. // Een bordpositie heef waarde 0 als leeg, 1 of twee voor de respectievelijke spelers-stenen.
  18.  
  19. public VORGame(){
  20.  
  21. // dit is de constructor. Het bord wordt klaargezet.
  22. initBord();
  23.  
  24.  
  25.  
  26. }
  27.  
  28.  
  29. public void initBord(){
  30. bord = new int[5][5];
  31. for (int i=0;i<5;i++){
  32. for (int j=0;j<5;j++){
  33. bord[i][j]=0;
  34. }
  35. }
  36. }
  37.  
  38.  
  39. public boolean bevatVOR(){
  40. // voor alle posities :
  41. // - check horizontale VOR
  42. // - check verticale VOR
  43. // - check diagonale VOR
  44. return false;
  45. }
  46.  
  47.  
  48. public void playTurn(){
  49. // doe een beurt:
  50. /*
  51. - CHECK of bord vol is. Indien niet :
  52. - vraag speler een om een kolomnnummer
  53. - plaatsSteen in kolom met juiste kleur
  54. - als dit een bevatVOR == true oplevert ==> WINNAAR
  55. Indien geen winnaar :
  56. - vraag speler twee om een kolomnnummer
  57. - plaatsSteen in kolom met juiste kleur
  58. - als dit een bevatVOR == true oplevert ==> WINNAAR
  59. KLAAR
  60. */
  61.  
  62.  
  63.  
  64. }
  65.  
  66.  
  67.  
  68. /**
  69. * Does a move based on the requested column and the team that plays
  70. * the move. It will check at what height the move will end, places
  71. * this inside of the 'bord' and forces the board to redraw
  72. *
  73. * @param column the column that is played
  74. * @param team the team that makes the move
  75. * @since 1.0
  76. */
  77. public void plaatsSteen(int column, int team){
  78. int placement = getLowestEmptySpace(bord[column]);
  79.  
  80. if(placement != -1) {
  81. bord[column][placement] = team;
  82. } else {
  83. throw new ColumnAlreadyFilledException(column);
  84. }
  85.  
  86. tekenBord();
  87. }
  88.  
  89. /**
  90. * Gets the lowest possible space inside of a row
  91. *
  92. * @param column the column that should be checked on an empty space
  93. * @return the lowest possible empty space. If the row is completely
  94. * filled, it will return -1
  95. * @since 1.0
  96. */
  97. private int getLowestEmptySpace(int[] column) {
  98. for(int i = 0; i < column.length; i++) {
  99. if(column[i] == 0) {
  100. return i;
  101. }
  102. }
  103. return -1;
  104. }
  105. public void tekenBord() {
  106. // teken het bord naar het scherm
  107. }
  108. }
  109.  
  110. /**
  111. * This Exception can be thrown when a column is played when the column
  112. * is already completely filled
  113. *
  114. * @author Mark van Wijk
  115. * @since 1.0
  116. */
  117. class ColumnAlreadyFilledException extends RuntimeException {
  118.  
  119. /**
  120. * Adds a message to the Exception so that it will be possible for
  121. * Dutch people to understand why this Exception is thrown
  122. *
  123. * @param column the filled column
  124. * @since 1.0
  125. */
  126. ColumnAlreadyFilledException(int column) {
  127. super("De kolom " + column + " is al volledig gevult");
  128. }
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement