ServidorJuegos/src/Sala4.java

37 lines
641 B
Java

import java.net.Socket;
public class Sala4 {
int nJugadores;
Socket[] jugadores;
Tablero4 tablero;
public Sala4() {
this.nJugadores = 0;
this.jugadores = new Socket[2];
this.tablero = new Tablero4();
}
public boolean aniadirJugador(Socket jugador) {
if(this.nJugadores <= 1 ) {
this.jugadores[this.nJugadores] = jugador;
this.nJugadores++;
return true;
}else {
return false;
}
}
public Socket getJugador1() {
return this.jugadores[0];
}
public Socket getJugador2() {
return this.jugadores[1];
}
public String toString() {
return String.valueOf(this.nJugadores) + "Cuatro en raya";
}
}