elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
27 Mayo 2012, 23:30  


Tema destacado: Recuperar cuenta de Google, GMail, Youtube

+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Java (Moderadores: Debci, Leyer)
| | | |-+  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 1,175 veces)
bjpenn

Desconectado Desconectado

Mensajes: 108



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

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

lo importante no es si haz caido si no es si puedes  levantarse
bjpenn

Desconectado Desconectado

Mensajes: 108



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

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


En línea

lo importante no es si haz caido si no es si puedes  levantarse
Debci
Moderador
***
Desconectado Desconectado

Mensajes: 1.945


Actualizate o muere!


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

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 por Debci » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
JUEGO DEL TRES EN RAYA « 1 2 »
Programación C/C++
Leonar 16 4,719 Último mensaje 26 Abril 2006, 15:48
por erconcor
tres en raya con integrdos
Electrónica
resistron 2 1,460 Último mensaje 24 Junio 2007, 21:24
por resistron
[C++] Tres en raya V1.00 (Act. V1.10)
Programación C/C++
JuaN-ThE-HaCKeR 9 1,439 Último mensaje 20 Febrero 2009, 12:30
por JuaN-ThE-HaCKeR
( Juego ) Tres en Raya con QT
Programación C/C++
VirucKingX 13 1,367 Último mensaje 14 Enero 2009, 02:54
por D4RIO
tres en raya sencillito en vb « 1 2 »
Programación Visual Basic
Daklon 20 2,695 Último mensaje 3 Noviembre 2010, 19:44
por 79137913
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines