Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * **************************************************************
- * Centro Universitário Senac *
- * TADS - A - 1ºSemestre de 2016 *
- * Professor : Willian Y. Honda *
- * *
- * Projeto Integrador I *
- * Arquivo: Jogo da Velha *
- * *
- * Alunos: *
- * Augusto Pereira Alencar *
- * João Marcos Issamu Hamasaki *
- * Walter Felipe Pinto *
- * *
- * Data de entrega: *
- * 05/06/2016 *
- ***************************************************************
- */
- package projeto_2_jogo_da_velha;
- import java.util.Scanner;
- public class Projeto_2_Jogo_Da_Velha {
- static String [][] inicializarTabuleiro(){
- String [][] tabuleiro = {{" * ", " * " , " * "},{" * ", " * ", " * "},{" * ", " * ", " * "}};
- return tabuleiro;
- }
- static void imprimirTabuleiro(String tabuleiro[][]){
- int []vetorLC = new int [2];
- vetorLC[0] = leiaCoordenadaLinha();
- vetorLC[1] = leiaCoordenadaColuna();
- tabuleiro = inicializarTabuleiro();
- tabuleiro[vetorLC[0]][vetorLC[1]] = " x ";
- String []vetorLinha = new String [3];
- String []vetorColuna = new String[3];
- System.out.println(" 1 | 2 | 3 |");
- for (int i = 0; i < vetorLinha.length; i++) {
- System.out.println("-----------------");
- System.out.print(i+1+" ");
- for (int j = 0; j < vetorColuna.length; j++) {
- System.out.print("|" +tabuleiro[i][j] + "|");
- }
- System.out.println("");
- }
- // System.out.println(" 1 | 2 | 3 |");
- // System.out.println("-----------------");
- // System.out.println("1 | * | * | * |");
- // System.out.println("-----------------");
- // System.out.println("2 | * | * | * |");
- // System.out.println("-----------------");
- // System.out.println("3 | * | * | * |");
- }
- static int imprimeMenuPrincipal(){
- Scanner leitor = new Scanner(System.in);
- int opcao;
- System.out.println("---- BEM VINDO AO JOGO DA VELHA ----");
- System.out.println("1 - JOGADOR VS. JOGADOR");
- System.out.println("2 - JOGADOR VS. MÁQUINA MODO FACIL");
- System.out.println("3 - JOGADOR VS. MÁQUINA MODO DIFÍCIL");
- System.out.println("4 - SAIR DO JOGO");
- System.out.println("------------------------------------");
- System.out.print("DIGITE OPÇÃO (1 - 4): ");
- while(true){
- opcao = leitor.nextInt();
- if (opcao <= 4 && opcao >= 1 ){
- break;
- }
- else {
- System.out.print("OPCÃO INVALIDA. DIGITE NOVAMENTE: ");
- }
- }
- return opcao;
- }
- static int leiaCoordenadaLinha(){
- Scanner leitor = new Scanner(System.in);
- int linha = 0;
- System.out.print("DIGITE A LINHA EM QUE QUERIA JOGAR(1 - 3): ");
- while(true){
- linha = leitor.nextInt();
- if(linha <= 3 && linha >= 1){
- break;
- }
- else{
- System.out.print("OPÇÃO INVALIDA. DIGITE NOVAMENTE: ");
- }
- }
- if(linha == 1)
- linha = linha - 1;
- if(linha == 2)
- linha = linha - 1;
- if(linha == 3)
- linha = linha - 1;
- return linha;
- }
- static int leiaCoordenadaColuna(){
- Scanner leitor = new Scanner(System.in);
- int coluna = 0;
- System.out.print("DIGITE A COLUNA EM QUE QUEIRA JOGAR(1 - 3): ");
- while(true){
- coluna = leitor.nextInt();
- if (coluna <= 3 && coluna >= 1){
- break;
- }
- else {
- System.out.print("POSIÇÃO INVALIDA. DIGITE NOVAMENTE: ");
- }
- }
- if(coluna == 1)
- coluna = coluna - 1;
- if(coluna == 2)
- coluna = coluna - 1;
- if(coluna == 3)
- coluna = coluna - 1;
- return coluna;
- }
- static void imprimePontuacao(){
- System.out.println("******* PLACAR *******");
- System.out.println("JOGADOR [X] : ");
- System.out.println("JOGADOR [O] : ");
- }
- static boolean posicaoValida(){
- boolean valida = true;
- int linha = leiaCoordenadaLinha();
- int coluna = leiaCoordenadaColuna();
- return valida;
- }
- static void verificaVencedor(){
- }
- static void verificaVelha(){
- }
- static int[] modoJogador(){
- int []vetorLC = new int [2];
- vetorLC[0] = leiaCoordenadaLinha();
- vetorLC[1] = leiaCoordenadaColuna();
- return vetorLC;
- // linha = leiaCoordenadaLinha(); -----------------------------------------------
- // coluna = leiaCoordenadaColuna();
- // int linha = leiaCoordenadaLinha();
- // int coluna = leiaCoordenadaColuna();
- // String [][] tabuleiro1 = new String [3][3];
- // tabuleiro[linha][coluna] = " x ";
- //
- }
- static void modoFacil(){
- }
- static void modoDificil(){
- }
- static void jogar(String tabuleiro[][], int []vetor){
- tabuleiro = inicializarTabuleiro();
- tabuleiro[vetor[0]][vetor[1]] = " x ";
- }
- static int[] jogadaUsuario(){
- int []vetorLC = new int [2];
- vetorLC[0] = leiaCoordenadaLinha();
- vetorLC[1] = leiaCoordenadaColuna();
- return vetorLC;
- // linha = leiaCoordenadaLinha();
- // coluna = leiaCoordenadaColuna();
- // int linha = leiaCoordenadaLinha();
- // int coluna = leiaCoordenadaColuna();
- // String [][] tabuleiro1 = new String [3][3];
- // tabuleiro[linha][coluna] = " x ";
- //
- }
- static void jogadaMaquinaFacil(){
- }
- static void jogadaMaquinaDificil(){
- }
- static void iniciaJogo(){
- }
- public static void main(String[] args) {
- imprimeMenuPrincipal();
- String [][] tabuleiro = inicializarTabuleiro();
- imprimirTabuleiro(tabuleiro);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement