elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Java
| | | |-+  juego tres en raya
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: juego tres en raya  (Leído 14,397 veces)
bengy


Desconectado Desconectado

Mensajes: 501


mis virtudes y defectos son inseparables


Ver Perfil WWW
juego tres en raya
« en: 26 Octubre 2011, 18:13 pm »

Código:
import java.util.*;
public class TresRaya{
char asterisco;
char cero;
char [][] matriz;
String juego=" ";
boolean bandera=false;

public TresRaya(){
asterisco='*';
cero='o';
matriz= new char [3][3];
}

public char [][] llenar(){
for(int i=0;    i<=2;  i++){
for(int j=0;    j<=2;  j++){
   
        matriz[i][j]='t';
        //llenamos con t por tres en raya
}
}
return matriz;
}
public String poner1(int fila, int columna, char caracter){
if(bandera==false){
for(int i=0;    i<=2;  i++){
for(int j=0;    j<=2;  j++){
    if (i==fila && j==columna){
        if(caracter=='*' && matriz[i][j]=='t'){
        matriz[i][j]=caracter; }
}
}
}
if(matriz[0][0]=='*' && matriz[0][1]=='*' && matriz[0][2]=='*'){ juego="gano jugador 1"; }
if(matriz[1][0]=='*' && matriz[1][1]=='*' && matriz[1][2]=='*'){ juego="gano jugador 1"; }
if(matriz[2][0]=='*' && matriz[2][1]=='*' && matriz[2][2]=='*'){ juego="gano jugador 1"; }
if(matriz[0][0]=='*' && matriz[1][1]=='*' && matriz[2][2]=='*'){ juego="gano jugador 1"; }
if(matriz[0][0]=='*' && matriz[1][0]=='*' && matriz[2][0]=='*'){ juego="gano jugador 1"; }
if(matriz[0][1]=='*' && matriz[1][1]=='*' && matriz[2][1]=='*'){ juego="gano jugador 1"; }
if(matriz[0][2]=='*' && matriz[1][2]=='*' && matriz[2][2]=='*'){ juego="gano jugador 1"; }
if(matriz[0][2]=='*' && matriz[1][1]=='*' && matriz[0][0]=='*'){ juego="gano jugador 1"; }
bandera=true;
}
else{ juego="no es su turno";}
return juego;
}

public String poner2(int fila, int columna, char caracter){
if(bandera==true){
for(int i=0;    i<=2;  i++){
for(int j=0;    j<=2;  j++){
    if (i==fila && j==columna){
        if(caracter=='o'  && matriz[i][j]=='t' ){
        matriz[i][j]=caracter; }
    }
}
}
if(matriz[0][0]=='o' && matriz[0][1]=='o' && matriz[0][2]=='o'){ juego="gano jugador 2"; }
if(matriz[1][0]=='o' && matriz[1][1]=='o' && matriz[1][2]=='o'){ juego="gano jugador 2"; }
if(matriz[2][0]=='o' && matriz[2][1]=='o' && matriz[2][2]=='o'){ juego="gano jugador 2"; }
if(matriz[0][0]=='o' && matriz[1][1]=='o' && matriz[2][2]=='o'){ juego="gano jugador 2"; }
if(matriz[0][0]=='o' && matriz[1][0]=='o' && matriz[2][0]=='o'){ juego="gano jugador 2"; }
if(matriz[0][1]=='o' && matriz[1][1]=='o' && matriz[2][1]=='o'){ juego="gano jugador 2"; }
if(matriz[0][2]=='o' && matriz[1][2]=='o' && matriz[2][2]=='o'){ juego="gano jugador 2"; }
if(matriz[0][2]=='o' && matriz[1][1]=='o' && matriz[0][0]=='o'){ juego="gano jugador 2"; }
bandera=false;
}
else{ juego="no es su turno";}
return juego;
}


public void mostrar(){
for(int i=0;    i<=2;  i++){
for(int j=0;    j<=2;  j++){
    System.out.println(matriz[i][j]);
}
}

}
}


En línea

bengy


Desconectado Desconectado

Mensajes: 501


mis virtudes y defectos son inseparables


Ver Perfil WWW
Re: juego tres en raya
« Respuesta #1 en: 30 Octubre 2011, 22:23 pm »

alguien me da ideas para hacer la intefaz bueno acorde con el code


En línea

Debci
Wiki

Desconectado Desconectado

Mensajes: 2.021


Actualizate o muere!


Ver Perfil WWW
juego tres en raya
« Respuesta #2 en: 31 Octubre 2011, 08:17 am »

El mensaje 'juego tres en raya' fue bloqueado
Incumplimiento de las normas, leetelas por favor.
Leer reglas:
http://foro.elhacker.net/reglas

-Doble post
-Título incompleto (no especificas tu problema)
-Mensajes vacíos respecto a lo que quieres que te hagan.
-No preguntas ninguna duda concreta, solo pides que te lo hagan.
-Aquí no se hacen tareas.
« Última modificación: 31 Octubre 2011, 08:19 am por Debci » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
tres en raya con integrdos
Electrónica
resistron 2 3,052 Último mensaje 24 Junio 2007, 21:24 pm
por resistron
Problema en el tres en Raya
Java
H4CKO_R 4 3,622 Último mensaje 31 Diciembre 2008, 20:56 pm
por Castiblanco
Aporte - Tres en Raya (con IA)
Programación Visual Basic
rob1104 9 9,863 Último mensaje 9 Marzo 2009, 22:35 pm
por peib0l
Juego de Tres en raya C#
.NET (C#, VB.NET, ASP)
AlexPro 4 15,953 Último mensaje 4 Julio 2012, 17:31 pm
por AlexPro
Juego tres en raya
Programación C/C++
carl221 6 3,326 Último mensaje 18 Mayo 2014, 22:21 pm
por MeCraniDOS
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines