Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package Juego;

import Juego.Exceptions.Lectura.LeerException;
import Juego.Exceptions.Lectura.LeerIncorrectoException;

public interface Comando {
void ayuda(boolean haTirado);
void imprimirTablero();
void jugador();
boolean tirarDados(boolean haTirado, String[] entradaPartida);
void comprar(String[] entradaPartida, boolean haTirado);
boolean tirarDados(boolean haTirado, String[] entradaPartida) throws LeerException;
void comprarComando(String[] entradaPartida, boolean haTirado);
void edificar(String[] entradaPartida);
void venderEdificio(String[] entradaPartida);
void hipotecar(String[] entradaPartida);
void deshipotecar(String[] entradaPartida);
void hipotecar(String[] entradaPartida) throws LeerIncorrectoException;
void deshipotecar(String[] entradaPartida) throws LeerIncorrectoException;
void bancarrota();
void describirJugador(String[] entradaPartida);
void describirCasilla(String s);
Expand All @@ -19,8 +22,8 @@ public interface Comando {
void listarEnVenta();
void listarEdificiosColor(String[] entradaPartida);
void listarEdificios();
void salirCarcel();
void pagarDeuda();
void salirCarcel() throws LeerException;
void pagarDeuda() throws LeerException;
boolean acabarTurno(boolean haTirado);
void cambiarMovimiento(boolean haTirado);
void estadisticas();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

public interface Consola {
void imprimir(String mensaje);
void imprimirError(String mensaje);
String leer(String descripcion);
String[] leerFragmentado(String descripcion);
String[] leerConsolaFragmentado(String descripcion);
int leerInt(String descripcion);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package Juego;


import Juego.Exceptions.Lectura.LeerException;
import Juego.Exceptions.Lectura.LeerIntException;

import java.util.Scanner;

public class ConsolaNormal implements Consola{
public final class ConsolaNormal implements Consola{

@Override
public void imprimir(String mensaje) {
Expand All @@ -15,17 +19,28 @@ public String leer(String descripcion) {
Scanner entrada = new Scanner(System.in);
return entrada.nextLine();
}
public void imprimirError(String mensaje) {
System.out.println(mensaje);
}

@Override
public String[] leerFragmentado(String descripcion) {
System.out.println(descripcion);
public String[] leerConsolaFragmentado(String descripcion) {
System.out.print(descripcion);
Scanner entrada = new Scanner(System.in);
String entradaString = entrada.nextLine();
return entradaString.split(" ");
}
public int leerInt (String descripcion){
System.out.println(descripcion);
Scanner entrada = new Scanner(System.in);
return entrada.nextInt();
try {
try {
System.out.println(descripcion);
Scanner entrada = new Scanner(System.in);
return entrada.nextInt();
} catch (Exception e) {
throw new LeerIntException();
}
}catch(LeerException le){
return leerInt(descripcion);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package Juego.Exceptions;

import Procesos.Jugador;

public class AlquilerDineroInsufException extends JuegoException {
private final Jugador cobrador;
private final int dineroPendiente;
public AlquilerDineroInsufException(Jugador j, int valor) {
super("DineroInsuf");
cobrador = j;
dineroPendiente = valor;
}

public int getDineroPendiente() {
return dineroPendiente;
}

public Jugador getCobrador() {
return cobrador;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package Juego.Exceptions;

public class CasillaInexistenteException extends JuegoException {

public CasillaInexistenteException() {
super("Esta casilla no existe...");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package Juego.Exceptions.Comandos;

import Juego.Exceptions.JuegoException;

public class ComandoBancarrotaException extends ComandoException{
public ComandoBancarrotaException() {
super("No puedes ejecutar esta acción estando en bancarrota, la partida se ha acabado para ti.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package Juego.Exceptions.Comandos;

import Juego.Exceptions.JuegoException;

public class ComandoException extends JuegoException {
public ComandoException(String mensaje) {
super(mensaje);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package Juego.Exceptions.Comandos;

public class ComandoNoHaTiradoException extends ComandoException {
public ComandoNoHaTiradoException() {
super("Aun no has tirado los dados. Tiralos para poder comprar propiedades");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package Juego.Exceptions.Comandos;

public class ComandoNoMasComprasException extends ComandoException {

public ComandoNoMasComprasException() {
super("No puedes hacer más compras en este turno...");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package Juego.Exceptions.Comprar;

import Juego.Exceptions.JuegoException;
import Juego.Juego;

public class ComprarException extends JuegoException {
public ComprarException(String mensaje) {
super(mensaje);
Juego.getConsolaNormal().imprimir("Error al comprar:");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package Juego.Exceptions.Comprar;

public class ComprarExceptionCasillaConDueno extends ComprarException {
public ComprarExceptionCasillaConDueno() {
super("Esta casilla ya tiene dueño");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package Juego.Exceptions.Comprar;

public class ComprarExceptionCasillaDistinta extends ComprarException {
public ComprarExceptionCasillaDistinta() {
super("No puedes comprar una casilla sobre la que no estás");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package Juego.Exceptions.Comprar;

public class ComprarExceptionCasillaNoPropiedad extends ComprarException {
public ComprarExceptionCasillaNoPropiedad(){
super("Casilla no comprable");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package Juego.Exceptions.Comprar;

import Procesos.Jugador;

public class ComprarExceptionDineroInsuficiente extends ComprarException {
public ComprarExceptionDineroInsuficiente() {
super("Dinero insuficiente");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package Juego.Exceptions.Hipotecar;

public class HipotecarCasillaInexistenteException extends HipotecarException {

public HipotecarCasillaInexistenteException() {
super("Esta casilla no existe...");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package Juego.Exceptions.Hipotecar;

public class HipotecarCasillanNoHipotecableException extends HipotecarException {

public HipotecarCasillanNoHipotecableException() {
super("Esta casilla no es hipotecable.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package Juego.Exceptions.Hipotecar;

import Juego.Exceptions.JuegoException;

public class HipotecarException extends JuegoException {
public HipotecarException(String mensaje) {
super(mensaje);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package Juego.Exceptions.Hipotecar;

public class HipotecarPropiedadDeOtro extends HipotecarException {

public HipotecarPropiedadDeOtro() {
super("No puedes hipotecar una casilla que no es tuya");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package Juego.Exceptions.Hipotecar;

public class desHipotecarPropiedadDeOtro extends HipotecarException {

public desHipotecarPropiedadDeOtro() {
super("No puedes deshipotecar una casilla que no es tuya");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package Juego.Exceptions;

import Juego.Exceptions.Hipotecar.HipotecarException;
import Juego.Juego;

public class JuegoException extends Exception{
public JuegoException(String mensaje) {
super("\u001B[31m"+mensaje+"\u001B[0m");
Juego.getConsolaNormal().imprimirError("\u001B[31m" + mensaje + "\u001B[0m");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package Juego.Exceptions.Lectura;

import Juego.Exceptions.JuegoException;
import Juego.Juego;

public class LeerException extends JuegoException {
public LeerException(String mensaje) {
super(mensaje);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package Juego.Exceptions.Lectura;

public class LeerIncorrectoException extends LeerException {

public LeerIncorrectoException() {
super("No se reconoce la acción... Introduce 'ayuda' para ver tus opciones.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package Juego.Exceptions.Lectura;

public class LeerIntException extends LeerException {

public LeerIntException() {
super("Debes introducir un número entero...");
}

}
Loading