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 { ...@@ -10,7 +10,8 @@ public class ByteGrayColor implements GrayColor {
private static final int MAXIMUM_GRAY_LEVEL = 255; private static final int MAXIMUM_GRAY_LEVEL = 255;
private static final int OPACITY = 1; 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; private final int grayLevel;
...@@ -20,19 +21,17 @@ public class ByteGrayColor implements GrayColor { ...@@ -20,19 +21,17 @@ public class ByteGrayColor implements GrayColor {
} }
public ByteGrayColor(int grayLevel) { public ByteGrayColor(int grayLevel) {
// TODO : Corriger l'initialisation de la propriété grayLevel de l'instance. this.grayLevel = grayLevel;
this.grayLevel = 0;
} }
public ByteGrayColor(double luminosity) { public ByteGrayColor(double luminosity) {
// TODO : Corriger l'initialisation de la propriété grayLevel de l'instance. this.grayLevel = (int) (luminosity * MAXIMUM_GRAY_LEVEL);
this.grayLevel = 0;
} }
@Override @Override
public double getLuminosity() { public double getLuminosity() {
// TODO : Retourner la luminosité de la couleur (entre 0 noir et 1 blanc) return this.grayLevel / (double) MAXIMUM_GRAY_LEVEL;
return 0;
} }
@Override @Override
...@@ -44,8 +43,7 @@ public class ByteGrayColor implements GrayColor { ...@@ -44,8 +43,7 @@ public class ByteGrayColor implements GrayColor {
@Override @Override
public int compareTo(GrayColor o) { public int compareTo(GrayColor o) {
// TODO : Retourner la différence de niveau de gris. return Double.compare(this.getLuminosity(), o.getLuminosity());
return 0;
} }
@Override @Override
......
...@@ -5,7 +5,6 @@ import static org.assertj.core.api.Assertions.*; ...@@ -5,7 +5,6 @@ import static org.assertj.core.api.Assertions.*;
public class ByteGrayColorTest { public class ByteGrayColorTest {
@Test @Test
@Disabled
public void testGetLuminosity_whenColorCreatedWithGrayLevel(){ public void testGetLuminosity_whenColorCreatedWithGrayLevel(){
ByteGrayColor black = new ByteGrayColor(0); ByteGrayColor black = new ByteGrayColor(0);
ByteGrayColor white = new ByteGrayColor(255); ByteGrayColor white = new ByteGrayColor(255);
...@@ -14,7 +13,6 @@ public class ByteGrayColorTest { ...@@ -14,7 +13,6 @@ public class ByteGrayColorTest {
} }
@Test @Test
@Disabled
public void testGetLuminosity_whenColorCreatedWithLuminosity(){ public void testGetLuminosity_whenColorCreatedWithLuminosity(){
ByteGrayColor color1 = new ByteGrayColor(.25); ByteGrayColor color1 = new ByteGrayColor(.25);
ByteGrayColor color2 = new ByteGrayColor(.75); ByteGrayColor color2 = new ByteGrayColor(.75);
...@@ -23,7 +21,6 @@ public class ByteGrayColorTest { ...@@ -23,7 +21,6 @@ public class ByteGrayColorTest {
} }
@Test @Test
@Disabled
public void testCompareTo_whenColorsCreatedWithGrayLevel(){ public void testCompareTo_whenColorsCreatedWithGrayLevel(){
ByteGrayColor color1 = new ByteGrayColor(100); ByteGrayColor color1 = new ByteGrayColor(100);
ByteGrayColor color2 = new ByteGrayColor(150); ByteGrayColor color2 = new ByteGrayColor(150);
...@@ -38,7 +35,6 @@ public class ByteGrayColorTest { ...@@ -38,7 +35,6 @@ public class ByteGrayColorTest {
} }
@Test @Test
@Disabled
public void testCompareTo_whenColorsCreatedWithLuminosity(){ public void testCompareTo_whenColorsCreatedWithLuminosity(){
ByteGrayColor color1 = new ByteGrayColor(0.20); ByteGrayColor color1 = new ByteGrayColor(0.20);
ByteGrayColor color2 = new ByteGrayColor(0.60); ByteGrayColor color2 = new ByteGrayColor(0.60);
...@@ -53,7 +49,6 @@ public class ByteGrayColorTest { ...@@ -53,7 +49,6 @@ public class ByteGrayColorTest {
} }
@Test @Test
@Disabled
public void testCompareTo_whenColorsCreatedWithLuminosityAndGrayLevel(){ public void testCompareTo_whenColorsCreatedWithLuminosityAndGrayLevel(){
ByteGrayColor color1 = new ByteGrayColor(0.); ByteGrayColor color1 = new ByteGrayColor(0.);
ByteGrayColor color2 = new ByteGrayColor(150); 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