Skip to content
Snippets Groups Projects
Commit d3c601d7 authored by SAEZ Theo's avatar SAEZ Theo
Browse files

Mise à jour de la class ByteGrayColor

parent 0649e55d
No related branches found
No related tags found
No related merge requests found
Pipeline #48817 passed
File added
No preview for this file type
......@@ -10,7 +10,8 @@ public class ByteGrayColor implements GrayColor {
private static final int MAXIMUM_GRAY_LEVEL = 255;
private static final int OPACITY = 1;
// TODO : add static ByteGrayColors WHITE and BLACK
public static final ByteGrayColor BLACK = new ByteGrayColor(MAXIMUM_GRAY_LEVEL);
public static final ByteGrayColor WHITE = new ByteGrayColor(MINIMUM_GRAY_LEVEL);
private final int grayLevel;
......@@ -20,19 +21,17 @@ public class ByteGrayColor implements GrayColor {
}
public ByteGrayColor(int grayLevel) {
// TODO : Corriger l'initialisation de la propriété grayLevel de l'instance.
this.grayLevel = 0;
this.grayLevel = grayLevel;
}
public ByteGrayColor(double luminosity) {
// TODO : Corriger l'initialisation de la propriété grayLevel de l'instance.
this.grayLevel = 0;
this.grayLevel = (int) (luminosity * MAXIMUM_GRAY_LEVEL);
}
@Override
public double getLuminosity() {
// TODO : Retourner la luminosité de la couleur (entre 0 noir et 1 blanc)
return 0;
return this.grayLevel / (double) MAXIMUM_GRAY_LEVEL;
}
@Override
......@@ -44,8 +43,7 @@ public class ByteGrayColor implements GrayColor {
@Override
public int compareTo(GrayColor o) {
// TODO : Retourner la différence de niveau de gris.
return 0;
return Double.compare(this.getLuminosity(), o.getLuminosity());
}
@Override
......
......@@ -5,7 +5,6 @@ import static org.assertj.core.api.Assertions.*;
public class ByteGrayColorTest {
@Test
@Disabled
public void testGetLuminosity_whenColorCreatedWithGrayLevel(){
ByteGrayColor black = new ByteGrayColor(0);
ByteGrayColor white = new ByteGrayColor(255);
......@@ -14,7 +13,6 @@ public class ByteGrayColorTest {
}
@Test
@Disabled
public void testGetLuminosity_whenColorCreatedWithLuminosity(){
ByteGrayColor color1 = new ByteGrayColor(.25);
ByteGrayColor color2 = new ByteGrayColor(.75);
......@@ -23,7 +21,6 @@ public class ByteGrayColorTest {
}
@Test
@Disabled
public void testCompareTo_whenColorsCreatedWithGrayLevel(){
ByteGrayColor color1 = new ByteGrayColor(100);
ByteGrayColor color2 = new ByteGrayColor(150);
......@@ -38,7 +35,6 @@ public class ByteGrayColorTest {
}
@Test
@Disabled
public void testCompareTo_whenColorsCreatedWithLuminosity(){
ByteGrayColor color1 = new ByteGrayColor(0.20);
ByteGrayColor color2 = new ByteGrayColor(0.60);
......@@ -53,7 +49,6 @@ public class ByteGrayColorTest {
}
@Test
@Disabled
public void testCompareTo_whenColorsCreatedWithLuminosityAndGrayLevel(){
ByteGrayColor color1 = new ByteGrayColor(0.);
ByteGrayColor color2 = new ByteGrayColor(150);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment