repositories
/
Persons_Comparator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a CSVUtils class for future usage.
[Persons_Comparator.git]
/
src
/
Eye.java
diff --git
a/src/Eye.java
b/src/Eye.java
index 59612440812c342dd6dd929b91936de79363d337..822e6f83dd3fc7aabc5bcf5d864671c828c6f999 100644
(file)
--- a/
src/Eye.java
+++ b/
src/Eye.java
@@
-1,7
+1,7
@@
import java.awt.Color;
import java.util.Arrays;
import java.awt.Color;
import java.util.Arrays;
-public class Eye
implements Comparable<Eye>
{
+public class Eye {
private String strColor;
private Color color;
private String[] colorsList = {"black", "blue", "brown", "green"};
private String strColor;
private Color color;
private String[] colorsList = {"black", "blue", "brown", "green"};
@@
-47,10
+47,14
@@
public class Eye implements Comparable<Eye> {
*/
public void setColor(String color) {
if (validateColor(color)) {
*/
public void setColor(String color) {
if (validateColor(color)) {
- if (color.equals("brown"))
+ if (color.equals("black"))
+ this.color = Color.black;
+ else if (color.equals("blue"))
+ this.color = Color.blue;
+ else if (color.equals("brown"))
this.color = new Color(88, 41, 0);
this.color = new Color(88, 41, 0);
- else
- this.color = Color.g
etColor(color)
;
+ else
if (color.equals("green"))
+ this.color = Color.g
reen
;
} else {
throw new IllegalArgumentException("Color must be" + this.colorListToString());
}
} else {
throw new IllegalArgumentException("Color must be" + this.colorListToString());
}
@@
-77,8
+81,7
@@
public class Eye implements Comparable<Eye> {
* @param eye
* @return
*/
* @param eye
* @return
*/
- @Override
- public int compareTo(Eye eye) {
+ public int distanceTo(Eye eye) {
double r_diff = this.getColor().getRed() - eye.getColor().getRed();
double g_diff = this.getColor().getGreen() - eye.getColor().getGreen();
double b_diff = this.getColor().getBlue() - eye.getColor().getBlue();
double r_diff = this.getColor().getRed() - eye.getColor().getRed();
double g_diff = this.getColor().getGreen() - eye.getColor().getGreen();
double b_diff = this.getColor().getBlue() - eye.getColor().getBlue();