From 96934805c916f474d87e99652833b3f1d6a56138 Mon Sep 17 00:00:00 2001
From: r20004714 <andrianinarisaina-cy.RAKOTOARISOA@etu.univ-amu.fr>
Date: Fri, 18 Nov 2022 20:37:56 +0100
Subject: [PATCH] =?UTF-8?q?T=C3=A2che=208(11.1)=20:=20Cr=C3=A9ation=20de?=
 =?UTF-8?q?=20la=20classe=20FloodGame,=20de=20ses=20attributs=20(Player=20?=
 =?UTF-8?q?player),(int=20totalFloodingArea)=20et=20(turn),=20compl=C3=A9t?=
 =?UTF-8?q?er=20toutes=20ses=20m=C3=A9thodes,=20en=20l'occurence=20"getSco?=
 =?UTF-8?q?re(Player=20player)",=20"boolean=20hasWon(Player=20player)"=20e?=
 =?UTF-8?q?t=20"boolean=20hasEnded()".?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/src/main/java/model/FloodGame.java | 32 ++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/app/src/main/java/model/FloodGame.java b/app/src/main/java/model/FloodGame.java
index 64d44a1..818b547 100644
--- a/app/src/main/java/model/FloodGame.java
+++ b/app/src/main/java/model/FloodGame.java
@@ -1,9 +1,9 @@
 package model;
-
 import javafx.beans.property.SimpleIntegerProperty;
-
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 public class FloodGame {
 
@@ -11,38 +11,47 @@ public class FloodGame {
     private final int totalFloodingArea;
     private final SimpleIntegerProperty turn  = new SimpleIntegerProperty(0);
 
+    //Constructeur de la calsse
     public FloodGame(int totalFloodingArea){
         this.totalFloodingArea = totalFloodingArea;
     }
 
+
     public void setPlayer(Player player){
         this.player = player;
     }
 
+
     public Player getPlayer(){
         return player;
     }
 
+
     public void setTurn(int value){
         turn.setValue(value);
     }
 
+
     public int  getTurn(){
         return turn.getValue();
     }
 
+
     public void  resetTurn() {
         setTurn(0);
     }
 
+
     public SimpleIntegerProperty getTurnProperty(){
         return turn;
     }
 
+
     public void incrementTurn(){
         setTurn(getTurn()+1);
     }
 
+
     public boolean isHumanTurn(){
         return getPlayer().isHuman();
     }
@@ -50,17 +59,30 @@ public class FloodGame {
 
     public int getPlayerScore(Player player) {
         // TODO
-        return 0;
+        Set<Cell> pendingCells = new HashSet();
+        int Cellcount = 0 ;
+        pendingCells.add(this.player.getStartCell())  ;
+
+
+        while (player.getStartCell().iterator().hasNext()) {
+            pendingCells.add(pendingCells.iterator().next()) ;
+            Cellcount++;
+        }
+
+        return Cellcount ;
     }
 
+
     public boolean hasWon(Player player){
         // TODO
-        return false;
+        return this.getPlayerScore(player) == this.totalFloodingArea;
     }
 
+
     public boolean hasEnded(){
         // TODO
-        return false;
+        return hasWon(player);
     }
 
 }
+
-- 
GitLab