Advertisement
Guest User

Untitled

a guest
May 28th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.84 KB | None | 0 0
  1. /*
  2. * **************************************************************
  3. * Centro Universitário Senac *
  4. * TADS - A - 1ºSemestre de 2016 *
  5. * Professor : Willian Y. Honda *
  6. * *
  7. * Projeto Integrador I *
  8. * Arquivo: Jogo da Velha *
  9. * *
  10. * Alunos: *
  11. * Augusto Pereira Alencar *
  12. * João Marcos Issamu Hamasaki *
  13. * Walter Felipe Pinto *
  14. * *
  15. * Data de entrega: *
  16. * 05/06/2016 *
  17. ***************************************************************
  18. */
  19.  
  20.  
  21. package projeto_2_jogo_da_velha;
  22.  
  23. import java.util.Scanner;
  24.  
  25. public class Projeto_2_Jogo_Da_Velha {
  26.  
  27.  
  28.  
  29. static String [][] inicializarTabuleiro(){
  30. String [][] tabuleiro = {{" * ", " * " , " * "},{" * ", " * ", " * "},{" * ", " * ", " * "}};
  31. return tabuleiro;
  32. }
  33.  
  34. static void imprimirTabuleiro(String tabuleiro[][]){
  35.  
  36. int []vetorLC = new int [2];
  37. vetorLC[0] = leiaCoordenadaLinha();
  38. vetorLC[1] = leiaCoordenadaColuna();
  39. tabuleiro = inicializarTabuleiro();
  40. tabuleiro[vetorLC[0]][vetorLC[1]] = " x ";
  41.  
  42. String []vetorLinha = new String [3];
  43. String []vetorColuna = new String[3];
  44. System.out.println(" 1 | 2 | 3 |");
  45. for (int i = 0; i < vetorLinha.length; i++) {
  46. System.out.println("-----------------");
  47. System.out.print(i+1+" ");
  48. for (int j = 0; j < vetorColuna.length; j++) {
  49. System.out.print("|" +tabuleiro[i][j] + "|");
  50. }
  51. System.out.println("");
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58. // System.out.println(" 1 | 2 | 3 |");
  59. // System.out.println("-----------------");
  60. // System.out.println("1 | * | * | * |");
  61. // System.out.println("-----------------");
  62. // System.out.println("2 | * | * | * |");
  63. // System.out.println("-----------------");
  64. // System.out.println("3 | * | * | * |");
  65. }
  66.  
  67. static int imprimeMenuPrincipal(){
  68. Scanner leitor = new Scanner(System.in);
  69. int opcao;
  70. System.out.println("---- BEM VINDO AO JOGO DA VELHA ----");
  71. System.out.println("1 - JOGADOR VS. JOGADOR");
  72. System.out.println("2 - JOGADOR VS. MÁQUINA MODO FACIL");
  73. System.out.println("3 - JOGADOR VS. MÁQUINA MODO DIFÍCIL");
  74. System.out.println("4 - SAIR DO JOGO");
  75. System.out.println("------------------------------------");
  76. System.out.print("DIGITE OPÇÃO (1 - 4): ");
  77. while(true){
  78. opcao = leitor.nextInt();
  79. if (opcao <= 4 && opcao >= 1 ){
  80. break;
  81. }
  82. else {
  83. System.out.print("OPCÃO INVALIDA. DIGITE NOVAMENTE: ");
  84. }
  85. }
  86. return opcao;
  87.  
  88. }
  89.  
  90. static int leiaCoordenadaLinha(){
  91. Scanner leitor = new Scanner(System.in);
  92. int linha = 0;
  93. System.out.print("DIGITE A LINHA EM QUE QUERIA JOGAR(1 - 3): ");
  94. while(true){
  95. linha = leitor.nextInt();
  96. if(linha <= 3 && linha >= 1){
  97. break;
  98. }
  99. else{
  100. System.out.print("OPÇÃO INVALIDA. DIGITE NOVAMENTE: ");
  101. }
  102. }
  103. if(linha == 1)
  104. linha = linha - 1;
  105. if(linha == 2)
  106. linha = linha - 1;
  107. if(linha == 3)
  108. linha = linha - 1;
  109. return linha;
  110. }
  111.  
  112. static int leiaCoordenadaColuna(){
  113. Scanner leitor = new Scanner(System.in);
  114. int coluna = 0;
  115. System.out.print("DIGITE A COLUNA EM QUE QUEIRA JOGAR(1 - 3): ");
  116. while(true){
  117. coluna = leitor.nextInt();
  118. if (coluna <= 3 && coluna >= 1){
  119. break;
  120. }
  121. else {
  122. System.out.print("POSIÇÃO INVALIDA. DIGITE NOVAMENTE: ");
  123. }
  124. }
  125. if(coluna == 1)
  126. coluna = coluna - 1;
  127. if(coluna == 2)
  128. coluna = coluna - 1;
  129. if(coluna == 3)
  130. coluna = coluna - 1;
  131. return coluna;
  132.  
  133. }
  134.  
  135. static void imprimePontuacao(){
  136. System.out.println("******* PLACAR *******");
  137. System.out.println("JOGADOR [X] : ");
  138. System.out.println("JOGADOR [O] : ");
  139. }
  140.  
  141. static boolean posicaoValida(){
  142. boolean valida = true;
  143. int linha = leiaCoordenadaLinha();
  144. int coluna = leiaCoordenadaColuna();
  145. return valida;
  146. }
  147.  
  148. static void verificaVencedor(){
  149.  
  150. }
  151.  
  152. static void verificaVelha(){
  153.  
  154. }
  155.  
  156. static int[] modoJogador(){
  157. int []vetorLC = new int [2];
  158. vetorLC[0] = leiaCoordenadaLinha();
  159. vetorLC[1] = leiaCoordenadaColuna();
  160.  
  161. return vetorLC;
  162.  
  163. // linha = leiaCoordenadaLinha(); -----------------------------------------------
  164. // coluna = leiaCoordenadaColuna();
  165.  
  166. // int linha = leiaCoordenadaLinha();
  167. // int coluna = leiaCoordenadaColuna();
  168. // String [][] tabuleiro1 = new String [3][3];
  169. // tabuleiro[linha][coluna] = " x ";
  170. //
  171. }
  172.  
  173. static void modoFacil(){
  174.  
  175. }
  176.  
  177. static void modoDificil(){
  178.  
  179. }
  180.  
  181. static void jogar(String tabuleiro[][], int []vetor){
  182. tabuleiro = inicializarTabuleiro();
  183. tabuleiro[vetor[0]][vetor[1]] = " x ";
  184.  
  185. }
  186.  
  187. static int[] jogadaUsuario(){
  188. int []vetorLC = new int [2];
  189. vetorLC[0] = leiaCoordenadaLinha();
  190. vetorLC[1] = leiaCoordenadaColuna();
  191.  
  192. return vetorLC;
  193.  
  194. // linha = leiaCoordenadaLinha();
  195. // coluna = leiaCoordenadaColuna();
  196.  
  197. // int linha = leiaCoordenadaLinha();
  198. // int coluna = leiaCoordenadaColuna();
  199. // String [][] tabuleiro1 = new String [3][3];
  200. // tabuleiro[linha][coluna] = " x ";
  201. //
  202. }
  203.  
  204. static void jogadaMaquinaFacil(){
  205.  
  206. }
  207.  
  208. static void jogadaMaquinaDificil(){
  209.  
  210. }
  211.  
  212. static void iniciaJogo(){
  213.  
  214. }
  215.  
  216.  
  217.  
  218. public static void main(String[] args) {
  219. imprimeMenuPrincipal();
  220. String [][] tabuleiro = inicializarTabuleiro();
  221. imprimirTabuleiro(tabuleiro);
  222.  
  223.  
  224.  
  225. }
  226.  
  227. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement