From 092af1f011794ec0981fbc9ab52e87f138af8d69 Mon Sep 17 00:00:00 2001 From: FARESSE Adam <adam.faresse@etu.univ-amu.fr> Date: Mon, 19 Oct 2020 00:26:51 +0200 Subject: [PATCH] Update Grid.java --- Grid.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Grid.java b/Grid.java index 7d3d88e..09e0d08 100644 --- a/Grid.java +++ b/Grid.java @@ -133,6 +133,29 @@ public class Grid implements Iterable<Cell> { } return tableau; } + private String countColorNeighbours(int rowIndex, int columnIndex) { + String CounterColorCell; + int Red = 0; + int Blue = 0; + for (Cell NeighboursCell : this.getNeighbours(rowIndex, columnIndex)) { + if (NeighboursCell.isAlive()) { + if ((NeighboursCell.getColor()).equals("Red")) { + Red+=1; + } + else { + Blue+=1; + } + } + } + if (Red>Blue) { + CounterColorCell="Red"; + } + else { + CounterColorCell="Blue"; + } + + return CounterColorCell; + } -- GitLab