From 62392406c7339692d6eda50b321073d9a2734a06 Mon Sep 17 00:00:00 2001 From: leama Date: Wed, 15 Mar 2023 09:58:29 +0100 Subject: [PATCH] Modif classe joueur (get set) --- src/Joueur.java | 82 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/src/Joueur.java b/src/Joueur.java index 77db3f5..a806c20 100644 --- a/src/Joueur.java +++ b/src/Joueur.java @@ -9,7 +9,7 @@ public class Joueur { private int positionX; 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.scoreAttaque = scoreAttaque; this.nbrPoints = nbrPoints; @@ -35,13 +35,13 @@ public class Joueur { public void tuer() { if (abs(Zombie.positionX - positionX)<=2 && abs(Zombie.positionY - positionY)<=2){ if (Zombie.positionX == positionX && Zombie.positionY == positionY) { - scoreVie = scoreVie - Zombie.pointAttaque; + scoreVie = scoreVie - Zombie.getPointAttaque(); } else { - if (Zombie.pointVie <= scoreAttaque) { - nbrPoints = nbrPoints + Zombie.pointVie; + if (Zombie.getPointDeVie() <= scoreAttaque) { + nbrPoints = nbrPoints + Zombie.getPointDeVie(); nbrZombiesTues = nbrZombiesTues + 1; - Zombie.pointVie = 0; + Zombie.setPointDeVie(0); } else { 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; + } }