En 4chan también hay buenos wallpapers, sobre todo de anime.
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menúpackage control;
import logica.Tablero;
import logica.Partida;
import java.util.Scanner;
public class Controlador {
//Método para los saltos de línea
public static String nuevalinea = System.getProperty("line.separator");
//Método para esperar X tiempo
public void esperar () {
try {
//Esperaremos 2 segundos para que el usuario vea qué tipo de instrucciones están ejecutándose
Thread.sleep (1*2000);
} catch (Exception e) {
}
}
private Partida partida;
private Scanner in;
private boolean fin;
public Controlador (Partida partida, Scanner in){
this.partida = partida;
this.in = in;
this.fin = false;
}
public void run(){
while (!fin){
//muestra turno
System.out.println(partida);
System.out.print("¿Que quieres hacer? ");
String comando;
comando = in.nextLine();
if(comando.equalsIgnoreCase("PONER")) {
System.out.print("Introduzca la columna: ");
int c = in.nextInt();
System.out.println(nuevalinea);
boolean mov = this.partida.ejecutaMovimiento(c);
}
/* else if (comando.equalsIgnoreCase("DESHACER")) {
boolean undo = this.partida.undo();
if (undo = false){
System.out.print("¡No es posible deshacer!");
}
}*/
else if (comando.equalsIgnoreCase("REINICIAR")) {
System.out.println("Reseteando el Juego..." + nuevalinea);
esperar();
this.partida.reset();
}
else if (comando.equalsIgnoreCase("SALIR")) {
System.out.println("Saliendo..." + nuevalinea);
fin = true;
}
else {
System.out.println("¡Comando incorrecto!");
}
}
}
}
package logica;
import logica.Tablero.FICHA;
public class Partida {
private FICHA turno;
private Tablero tablero;
private boolean terminada;
/* private int[] undo;
private int indexUndo;*/
public final static int FILAS = 6;
public final static int COLUMNAS = 6;
public Partida(){
this.tablero = new Tablero(FILAS,COLUMNAS);
}
public String toString(){
return this.tablero.toString();
}
public boolean partidaTerminada(){
return false;
}
public boolean ejecutaMovimiento(int c){
if (c <= FILAS) {
//Habría que poner la ficha referente al turno del jugador, he puesto la blanca solo para ver como funcionaría
this.tablero.ponFicha(2,c,FICHA.BLANCA);
//if (this.partida.partidaTerminada()) exit = true;
return true;
} else
return false;
}
public void reset(){
this.tablero = new Tablero(FILAS, COLUMNAS);
}
/* public boolean undo(){
}*/
private void buscarFila(){
}
private void comprobar(){
}
}
package logica;
import logica.Partida;
public class Tablero {
public enum FICHA {VACIA, BLANCA, NEGRA};
private int alto; //número de filas del tablero
private int ancho; //número de columnas del tablero
private FICHA[][] tablero; //array tipo FICHA
public String toString() {
String s = "";
for (int x = Partida.FILAS-1; x >= 0; x--) {
for (int y = 0; y < Partida.COLUMNAS; y++) {
if (this.tablero[x][y] == FICHA.VACIA) s=s+"O ";
else if (this.tablero[x][y] == FICHA.BLANCA) s=s+"B ";
else s= s + "N ";
}
s=s+System.getProperty("line.separator");
}
return s;
}
public Tablero(int nf, int nc) {
this.tablero = new FICHA[nf][nc];
this.ancho = nc;
this.alto = nf;
for (int x = 0; x < nf; x++) {
for (int y = 0; y < nc; y++) {
this.tablero[x][y] = FICHA.VACIA;
}
}
}
public void ponFicha(int f, int c, FICHA ficha) {
//c-1 se pone porque el array empieza en la columna 0
for (int x = 0; x <= Partida.FILAS; x++) {
//este bucle empieza a buscar la primera posición VACIA (de abajo a arriba) en la columna que hayas seleccionado,
//y coloca la ficha BLANCA en dicha posición
if (this.tablero[x][c-1] == FICHA.VACIA) {
this.tablero[x][c-1] = ficha;
//el break corta la ejecución del bucle
break;
}
}
}
public FICHA colorFicha() {
return FICHA.VACIA;
}
public FICHA getFicha(int f, int c) {
//devuelve la ficha en la posicion (f, c)
return this.tablero[f][c];
}
public boolean completo() {
//devuelve true solo si el tablero esta completo
//contador!!!
return false;
}
}
package main;
import java.util.Scanner;
import control.Controlador;
import logica.Partida;
public class Main {
private static Scanner in = new Scanner(System.in);
public static void main(String[] args) {
Partida partida = new Partida();
Controlador c = new Controlador(partida,in);
c.run();
}
}
package ArrayVACIA;
public class Main {
private String[][] array;
/* private final static int filas = 6;
private final static int columnas = 6;*/
public static void main(String[] args) {
Main ob = new Main();
ob.setArray();
System.out.println(ob.array[0][0]);
}
public void setArray() {
this.array[0][0] = "hola";
}
}
package ArrayVACIA;
public class Main {
private String[][] array;
private final int filas = 6;
private final int columnas = 6;
public static void main(String[] args) {
Main objeto = new Main();
System.out.println(objeto.array);
}
private Main() {
for (int i=0; i <= this.filas; i++) {
for (int j=0; j <= this.columnas; j++) {
this.array[i][j] = "0";
}
}
}
}