Skip to content
Snippets Groups Projects
Commit 836cc7cd authored by RAKOTOARISOA Andrianinarisaina cy's avatar RAKOTOARISOA Andrianinarisaina cy
Browse files

Tâche 4 (7.5) : Création de la classe RandomColorGenerator, avec son...

Tâche 4 (7.5) : Création de la classe RandomColorGenerator, avec son cosntructeur et la méthode "Color nextcolor(Cell cell)"
parent 22b3ec3e
No related branches found
No related tags found
No related merge requests found
package model;
import javafx.scene.paint.Color;
import util.RandomUtil;
import java.util.List;
import java.util.Random;
public class RandomColorGenerator implements ColorGenerator {
List<Color> colors ;
Random randomGenerator ;
//Constructeur de la classe
public void RandcomColorGenerator(List<Color> colors, Random randomGenerator) {
this.colors = colors ;
this.randomGenerator = randomGenerator ;
}
//Renvoie une couleur tirée au hasard dans la liste "colors"
@Override
public Color nextColor(Cell cell) {
RandomUtil RandomColor = new RandomUtil();
return RandomColor.randomElement(this.colors, this.randomGenerator);
}
}
package util; package util;
import javafx.scene.paint.Color;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public class RandomUtil { public class RandomUtil {
...@@ -9,7 +11,7 @@ public class RandomUtil { ...@@ -9,7 +11,7 @@ public class RandomUtil {
public void RandomUtil() {} public void RandomUtil() {}
//Constructeur //Constructeur
private RandomUtil() {}; public RandomUtil() {};
//Méthode demandée par l'exercice : concerne un tableau //Méthode demandée par l'exercice : concerne un tableau
public static <T> T randomElement(T[] elements, Random random) { public static <T> T randomElement(T[] elements, Random random) {
...@@ -22,6 +24,5 @@ public class RandomUtil { ...@@ -22,6 +24,5 @@ public class RandomUtil {
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment