From 7300b8cbe45cbd3d273aea391c5f6ae779d1aa51 Mon Sep 17 00:00:00 2001
From: malop <malo.poussardin@etu.univ-amu.fr>
Date: Fri, 22 Nov 2024 16:42:23 +0100
Subject: [PATCH] =?UTF-8?q?TP7=20=C3=A9tape=202?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/main/java/model/State.java                    |  9 +++++++--
 src/main/java/model/automata/GameOfLifeState.java | 13 +++++++++----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/main/java/model/State.java b/src/main/java/model/State.java
index 1954558..3ac29c0 100644
--- a/src/main/java/model/State.java
+++ b/src/main/java/model/State.java
@@ -44,7 +44,12 @@ public interface State<S> {
      * @return The number of times the specified state appears in the list of neighbors.
      */
     static <T> int count(T state, List<T> neighbours) {
-        //TODO: à compléter
-        return 0;
+        int count = 0;
+        for (T neighbour : neighbours) {
+            if (state.equals(neighbour)) {
+                count++;
+            }
+        }
+        return count;
     }
 }
\ No newline at end of file
diff --git a/src/main/java/model/automata/GameOfLifeState.java b/src/main/java/model/automata/GameOfLifeState.java
index 12ee370..7f8cb8b 100644
--- a/src/main/java/model/automata/GameOfLifeState.java
+++ b/src/main/java/model/automata/GameOfLifeState.java
@@ -14,14 +14,19 @@ public enum GameOfLifeState implements State<GameOfLifeState> {
 
     @Override
     public Color getColor() {
-        //TODO: à compléter
-        return Color.BLACK;
+        return this == ALIVE ? Color.RED : Color.WHITE;
     }
 
     @Override
     public GameOfLifeState next() {
-        //TODO: à compléter
-        return null;
+        switch (this) {
+            case ALIVE:
+                return DEAD;
+                case DEAD:
+                    return ALIVE;
+                    default:
+                        return ALIVE;
+        }
     }
 
     @Override
-- 
GitLab