Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. public class JogoDaVelha {
  2.  
  3. protected static int [][] matriz = new int[3][3];
  4.  
  5. private static final String jogador1 = "1";
  6. private static final String jogador2 = "2";
  7.  
  8. protected int vazio = 0;
  9.  
  10. private int coluna;
  11.  
  12. private boolean linha;
  13.  
  14. public JogoDaVelha() {
  15. ZerarTabuleiro();
  16. }
  17.  
  18. public void ZerarTabuleiro() {
  19. for(int i = 0; i < 3; i++) {
  20. for(int j = 0; j < 3; j++) {
  21. matriz[i][j] = vazio;
  22. }
  23. }
  24. }
  25.  
  26. public void desenharGrade(){
  27. System.out.println();
  28. for(int linha = 0 ; linha < 3 ; linha++){
  29. for(int coluna = 0 ; coluna < 3 ; coluna++){
  30. if(matriz[linha][coluna] == 1){
  31. System.out.print(" X ");
  32. }
  33. if(matriz[linha][coluna] == 2){
  34. System.out.print(" O ");
  35. }
  36. if(matriz[linha][coluna] == 0){
  37. System.out.print(" ");
  38. }
  39.  
  40. if(coluna == 0 || coluna == 1)
  41. System.out.print("|");
  42. }
  43. System.out.println();
  44. }
  45. }
  46.  
  47. public boolean verificaJogada(int linha, int coluna) {
  48. if (this.linha || this.coluna > 2) {
  49. return false;
  50. } else {
  51. return true;
  52. }
  53. }
  54.  
  55.  
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement