Modif classe joueur (get set)

This commit is contained in:
leama 2023-03-15 09:58:29 +01:00
parent 177924a265
commit 62392406c7
1 changed files with 77 additions and 5 deletions

View File

@ -9,7 +9,7 @@ public class Joueur {
private int positionX; private int positionX;
private int positionY; private int positionY;
Joueur (int scoreVie, int scoreAttaque, int nbrPoints, int nbrZombiesTues, int positionX, int positionY){ public Joueur (int scoreVie, int scoreAttaque, int nbrPoints, int nbrZombiesTues, int positionX, int positionY){
this.scoreVie = scoreVie; this.scoreVie = scoreVie;
this.scoreAttaque = scoreAttaque; this.scoreAttaque = scoreAttaque;
this.nbrPoints = nbrPoints; this.nbrPoints = nbrPoints;
@ -35,13 +35,13 @@ public class Joueur {
public void tuer() { public void tuer() {
if (abs(Zombie.positionX - positionX)<=2 && abs(Zombie.positionY - positionY)<=2){ if (abs(Zombie.positionX - positionX)<=2 && abs(Zombie.positionY - positionY)<=2){
if (Zombie.positionX == positionX && Zombie.positionY == positionY) { if (Zombie.positionX == positionX && Zombie.positionY == positionY) {
scoreVie = scoreVie - Zombie.pointAttaque; scoreVie = scoreVie - Zombie.getPointAttaque();
} }
else { else {
if (Zombie.pointVie <= scoreAttaque) { if (Zombie.getPointDeVie() <= scoreAttaque) {
nbrPoints = nbrPoints + Zombie.pointVie; nbrPoints = nbrPoints + Zombie.getPointDeVie();
nbrZombiesTues = nbrZombiesTues + 1; nbrZombiesTues = nbrZombiesTues + 1;
Zombie.pointVie = 0; Zombie.setPointDeVie(0);
} }
else { else {
Zombie.pointVie = Zombie.pointVie - scoreAttaque; Zombie.pointVie = Zombie.pointVie - scoreAttaque;
@ -49,6 +49,78 @@ public class Joueur {
} }
} }
} }
public int getScoreVie() {
return scoreVie;
}
public void setScoreVie(int scoreVie) {
this.scoreVie = scoreVie;
}
public int getScoreAttaque() {
return scoreAttaque;
}
public void setScoreAttaque(int scoreAttaque) {
this.scoreAttaque = scoreAttaque;
}
public int getNbrPoints() {
return nbrPoints;
}
public void setNbrPoints(int nbrPoints) {
this.nbrPoints = nbrPoints;
}
public int getNbrZombiesTues() {
return nbrZombiesTues;
}
public void setNbrZombiesTues(int nbrZombiesTues) {
this.nbrZombiesTues = nbrZombiesTues;
}
public int getPositionX() {
return positionX;
}
public void setPositionX(int positionX) {
this.positionX = positionX;
}
public int getPositionY() {
return positionY;
}
public void setPositionY(int positionY) {
this.positionY = positionY;
}
} }