Ajout du package model et de ses composantes, modification de la "nomination" d'une variable

This commit is contained in:
valentinlucas 2021-10-12 09:19:15 +02:00
parent 24f5269c63
commit db7d533c90
4 changed files with 48 additions and 7 deletions

View File

@ -7,14 +7,14 @@ public abstract class AbstractPlayer {
private int id; private int id;
private Point position; private Point position;
private int ernergy; private int energy;
private Weapon weapon; private Weapon weapon;
private boolean shieldDeploy; private boolean shieldDeploy;
public AbstractPlayer(int id, Point position, int ernergy, Weapon weapon, boolean shieldDeploy) { public AbstractPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) {
this.id = id; this.id = id;
this.position = position; this.position = position;
this.ernergy = ernergy; this.energy = energy;
this.weapon = weapon; this.weapon = weapon;
this.shieldDeploy = shieldDeploy; this.shieldDeploy = shieldDeploy;
} }
@ -31,8 +31,8 @@ public abstract class AbstractPlayer {
return position; return position;
} }
public int getErnergy() { public int getEnergy() {
return ernergy; return energy;
} }
public Weapon getWeapon() { public Weapon getWeapon() {
@ -43,8 +43,8 @@ public abstract class AbstractPlayer {
return shieldDeploy; return shieldDeploy;
} }
public void setErnergy(int ernergy) { public void setEnergy(int energy) {
this.ernergy = ernergy; this.energy = energy;
} }
public void setPosition(Point position) { public void setPosition(Point position) {

View File

@ -0,0 +1,14 @@
package fr.lnl.game.server.model;
import java.util.List;
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

@ -0,0 +1,6 @@
package fr.lnl.game.server.model;
public interface ModelListener {
//à peut-être revoir
void updateModel(Object obj);
}

View File

@ -0,0 +1,21 @@
package fr.lnl.game.server.model;
public class ModelListening extends AbstractModelListening{
@Override
public void addListener(ModelListener e) {
this.listeners.add(e);
}
@Override
public void removalListener(ModelListener e) {
this.listeners.remove(e);
}
@Override
public void updateModel(Object obj) {
}
}