Skip to content
Snippets Groups Projects
Commit 1abc5c20 authored by dragapsy's avatar dragapsy
Browse files

Corection de la methode Color nextColor(Cell cell).

parent 0a5c4ac6
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ public class SquareCell extends AbstractCell{
}
public SquareCell(Color color,List<Cell>neighbours){
SquareCell Cell=new SquareCell(color);
setNeighbours( neighbours);
setNeighbours(neighbours);
}
......
......@@ -6,20 +6,24 @@ import java.util.Random;
public class UniformColorGenerator implements ColorGenerator{
private Color color;
//code of color generator found on stackOverFlow;
// link : https://stackoverflow.com/questions/4246351/creating-random-colour-in-java
// but the color constructor with 3 parameter is not public, so I checked in the documentation of Color, and
// I found that there is a constructor with 4 parameter that is public since java 8;
// Link of the doc : https://docs.oracle.com/javase/8/javafx/api/javafx/scene/paint/Color.html
@Override
public Color nextColor(Cell cell) {
Random rand = new Random();
double red = rand.nextFloat();
double green = rand.nextFloat();
double blue = rand.nextFloat();
double opacity=rand.nextFloat();
Color randomColor = new Color(red, green, blue,opacity);
cell.setColor(randomColor);
return randomColor;
public Color nextColor(Cell cell) {
// Random rand = new Random();
// double red = rand.nextFloat();
// double green = rand.nextFloat();
// double blue = rand.nextFloat();
// double opacity=rand.nextFloat();
// Color randomColor = new Color(red, green, blue,opacity);
// cell.setColor(randomColor);
// return randomColor;
return this.color;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment