Refactored extends and implements

This commit is contained in:
Quentin Legot 2021-10-18 16:12:18 +02:00
parent 559c590b52
commit f5b26810b8
17 changed files with 47 additions and 20 deletions

View File

@ -0,0 +1,12 @@
package fr.lnl.game.server;
import fr.lnl.game.server.games.grid.Grid;
public class ServerMain {
public static void main(String[] args) {
Grid grid = new Grid(10,10);
grid.initGrid();
grid.printGrid();
}
}

View File

@ -0,0 +1,4 @@
package fr.lnl.game.server.games.action;
public abstract class AbstractAction implements Action {
}

View File

@ -1,6 +1,6 @@
package fr.lnl.game.server.games.action;
public class DeployShield implements Action{
public class DeployShield extends AbstractAction {
@Override
public void doAction() {

View File

@ -1,4 +1,4 @@
package fr.lnl.game.server.games.action;
public class DropBomb extends DropObject{
public class DropBomb extends DropObject {
}

View File

@ -1,4 +1,4 @@
package fr.lnl.game.server.games.action;
public class DropMine extends DropObject{
public class DropMine extends DropObject {
}

View File

@ -1,6 +1,6 @@
package fr.lnl.game.server.games.action;
public class DropObject implements Action{
public abstract class DropObject extends AbstractAction {
@Override
public void doAction() {

View File

@ -1,6 +1,6 @@
package fr.lnl.game.server.games.action;
public class Move implements Action{
public class Move extends AbstractAction {
@Override
public void doAction() {

View File

@ -1,6 +1,6 @@
package fr.lnl.game.server.games.action;
public class Nothing implements Action {
public class Nothing extends AbstractAction {
@Override
public void doAction() {

View File

@ -1,6 +1,6 @@
package fr.lnl.game.server.games.action;
public class Shot implements Action{
public class Shot extends AbstractAction {
@Override
public void doAction() {

View File

@ -1,4 +1,4 @@
package fr.lnl.game.server.games.grid;
public class Explosive implements Box{
public abstract class Explosive implements Box{
}

View File

@ -47,6 +47,11 @@ public class Grid {
}
// TODO: 18/10/2021
public void placePlayers() {
}
public void printGrid() {
for (int i = 0; i < x; i++) {
System.out.print("\n");
@ -77,10 +82,4 @@ public class Grid {
}
}
}
public static void main(String[] args) {
Grid grid = new Grid(10,10);
grid.initGrid();
grid.printGrid();
}
}

View File

@ -2,7 +2,7 @@ package fr.lnl.game.server.games.grid;
import fr.lnl.game.server.utils.Cardinal;
public class Wall implements Box{
public class Wall implements Box {
private Cardinal cardinal;
private int x;

View File

@ -3,7 +3,7 @@ package fr.lnl.game.server.games.player;
import fr.lnl.game.server.games.weapon.Weapon;
import fr.lnl.game.server.utils.Point;
public abstract class AbstractPlayer {
public abstract class AbstractPlayer implements Player {
private int id;
private Point position;

View File

@ -3,7 +3,8 @@ package fr.lnl.game.server.games.player;
import fr.lnl.game.server.games.weapon.Weapon;
import fr.lnl.game.server.utils.Point;
public class ComputerPlayer extends AbstractPlayer implements Player{
public class ComputerPlayer extends AbstractPlayer{
public ComputerPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) {
super(id, position, energy, weapon, shieldDeploy);
}

View File

@ -3,7 +3,7 @@ package fr.lnl.game.server.games.player;
import fr.lnl.game.server.games.weapon.Weapon;
import fr.lnl.game.server.utils.Point;
public class HumanPlayer extends AbstractPlayer implements Player{
public class HumanPlayer extends AbstractPlayer {
public HumanPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) {
super(id, position, energy, weapon, shieldDeploy);
}

View File

@ -1,10 +1,14 @@
package fr.lnl.game.server.model;
import java.util.List;
public abstract class AbstractModelListening implements ModelListener{
public abstract class AbstractModelListening implements ModelListener {
List<ModelListener> listeners;
public abstract void addListener(ModelListener e);
public abstract void removalListener(ModelListener e);
public void fireChange(){
for(ModelListener e : listeners){
e.updateModel(this);

View File

@ -1,5 +1,12 @@
package fr.lnl.game.server.utils;
public enum Cardinal {
NORTH,SOUTH,EAST,WEST,NORTH_EAST,NORTH_WEST,SOUTH_EAST,SOUTH_WEST
NORTH,
SOUTH,
EAST,
WEST,
NORTH_EAST,
NORTH_WEST,
SOUTH_EAST,
SOUTH_WEST
}