From ed407bcb3daefecb4e156027fc68b00f7ed0059d Mon Sep 17 00:00:00 2001 From: r20004714 <andrianinarisaina-cy.RAKOTOARISOA@etu.univ-amu.fr> Date: Mon, 14 Nov 2022 20:19:38 +0100 Subject: [PATCH] =?UTF-8?q?T=C3=A2che=204=20(7.3)=20:=20Modification=20de?= =?UTF-8?q?=20la=20classe=20UniforExceptOneGenerator,=20en=20y=20mettant?= =?UTF-8?q?=20son=20constructeur=20et=20en=20modifiant=20la=20m=C3=A9thode?= =?UTF-8?q?=20"nextColor"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/model/UniformExceptOneGenerator.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/src/main/java/model/UniformExceptOneGenerator.java diff --git a/app/src/main/java/model/UniformExceptOneGenerator.java b/app/src/main/java/model/UniformExceptOneGenerator.java new file mode 100644 index 0000000..e1255eb --- /dev/null +++ b/app/src/main/java/model/UniformExceptOneGenerator.java @@ -0,0 +1,26 @@ +package model; +import javafx.scene.paint.Color; + +public class UniformExceptOneGenerator implements ColorGenerator { + + Color uniformColor ; + Color exceptionColor ; + //"callednextColor" est une variable vérifiant si la méthode est appelé une fois ou plus + private static int callednextColor = 0 ; + + //Constructeur de la classe + public UniformExceptOneGenerator(Color uniformColor, Color exceptionColor) { + this.uniformColor = uniformColor ; + this.exceptionColor = exceptionColor; + } + + //Méthode demandée par l'exercice + @Override + public Color nextColor(Cell cell) { + if (callednextColor == 0 ) { + callednextColor++; + return this.uniformColor; + } + else return this.exceptionColor; + } +} -- GitLab