Coder Social home page Coder Social logo

algo3-tp2's People

Contributors

elias223 avatar eliaslamanna avatar fpaus avatar franyanes avatar rodrigueznazareno56 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

algo3-tp2's Issues

No se comprende la intensión del mensaje `recibirDanio`

 public void elJugadorQueSeQuedaSinEntidadesEsElPerdedorTest() throws PuntosInsuficientesExcepcion,
            CasilleroFueraDelLosLimitesDelTableroExcepcion, UnidadInvalidaException {
        Jugador jugador = new Jugador();
        Bando bando = new Bando(jugador);
        Tablero tablero = new Tablero(20, 20 , jugador, new Jugador());

        Unidad unidad1 = new Catapulta(bando);
        Unidad unidad2 = new Catapulta(bando);
        Unidad unidad3 = new Catapulta(bando);
        Unidad unidad4 = new Catapulta(bando);

        jugador.colocarUnidadEnCasillero(unidad1, tablero.getCasilleroEnPosicion(1,2));
        jugador.colocarUnidadEnCasillero(unidad2, tablero.getCasilleroEnPosicion(1,3));
        jugador.colocarUnidadEnCasillero(unidad3, tablero.getCasilleroEnPosicion(1,4));
        jugador.colocarUnidadEnCasillero(unidad4, tablero.getCasilleroEnPosicion(1,5));

        unidad1.generarDanio(Properties.vidaCatapulta);
        unidad2.generarDanio(Properties.vidaCatapulta);
        unidad3.generarDanio(Properties.vidaCatapulta);
        unidad4.generarDanio(Properties.vidaCatapulta);
        assertEquals(jugador.sigueEnJuego(), false);
    }

generarDanio no se entiende cual es el propósito. Y lo que esto evidencia que dos unidades se ataquen. Necesitan tener aquí el siguiente intercambio de mensajes:

uniadadAgresora.atacar(unidadAgredida);

Darle entidad a la coordenada

Debería existir una entiadad Punto.

    public Casillero getCasilleroEnPosicion(int x, int y) throws CasilleroFueraDelLosLimitesDelTableroExcepcion {
        try {
            return casilleros[x][y];
        } catch (ArrayIndexOutOfBoundsException ex) {
            throw new CasilleroFueraDelLosLimitesDelTableroExcepcion();
        }
    }

Será necesario cuando necesiten calcular distancias, casilleros a la izquierda, derecha, etc.

Exposición de estado interon - utilización métodos `get`

Este evidencia no ocultar la implementación de las clases resultando en un tren de puntos que evidencia alto acoplamiento. Ej.: unidad.getBando().getDuenio()

    public void setUnidadAlInicioDelJuego(Unidad unidad) throws CasilleroEnemigoExcepcion, CasilleroOcupadoExcepcion {
        if(unidad.getBando().getDuenio() != this.duenio.getDuenio()){
            throw new CasilleroEnemigoExcepcion();
        }
        estado.setUnidad(this, unidad);
    }

Aquí otro ejemplo más:

public Unidad comprarUnidad(Unidad unidad) throws PuntosInsuficientesExcepcion {
        if (unidad.getCosto() > puntosDisponibles) {
            throw new PuntosInsuficientesExcepcion();
        }
        return unidad;
    }

Otro ejemplo más:

    private int medirDistanciaEnX(Unidad unidadActual, Unidad unidadAliada) {
        int unidadActualCoordenadaX = unidadActual.getCasillero().getCoordenadaX();
        int unidadAliadaCoordenadaX = unidadAliada.getCasillero().getCoordenadaX();
        return (Math.abs(unidadAliadaCoordenadaX - unidadActualCoordenadaX));
    }

Como pueden quitar estos "getters" y reducirlos a la mínima expresión (mínima cantidad de ocurrencias).

Existen método que devuelven true/false

  • Método 1
    public boolean sigueEnJuego() {
        return this.sigueEnJuego;
    }
  • Método 2:
public boolean quedanPuntos(){
        return puntosDisponibles != 0;
    }
  • Metodo 3:
public boolean estaViva(){
        return this.estaViva;
    }

Pueden reemplazarlos utilizando algún mensaje que cumpla "Tell don't ask"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.