Basic classes structure that deal with Person attributes.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 8 Jan 2019 12:21:01 +0000 (13:21 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 8 Jan 2019 12:21:01 +0000 (13:21 +0100)
.idea/description.html
src/Eye.java [new file with mode: 0644]
src/Firstname.java [new file with mode: 0644]
src/Origin.java [new file with mode: 0644]
src/Person.java [new file with mode: 0644]
src/Size.java [new file with mode: 0644]
src/Weight.java [new file with mode: 0644]

index db5f12955691506605c7b50297b402dd1489554d..05a1fec86b8a397236566a2de0114287dbb209f1 100644 (file)
@@ -1 +1 @@
-<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
\ No newline at end of file
+<html>Persons Comparator <b>Java</b> application that includes a class with <code>main()</code> method</html>
\ No newline at end of file
diff --git a/src/Eye.java b/src/Eye.java
new file mode 100644 (file)
index 0000000..b02dbfc
--- /dev/null
@@ -0,0 +1,17 @@
+import java.awt.Color;
+
+public class Eye {
+    private Color color;
+
+    Eye(Color color) {
+        setColor(color);
+    }
+
+    public Color getColor() {
+        return color;
+    }
+
+    public void setColor(Color color) {
+        this.color = color;
+    }
+}
diff --git a/src/Firstname.java b/src/Firstname.java
new file mode 100644 (file)
index 0000000..2535c0e
--- /dev/null
@@ -0,0 +1,11 @@
+public class Firstname {
+    private String firstname;
+
+    public String getFirstname() {
+        return firstname;
+    }
+
+    public void setFirstname(String firstname) {
+        this.firstname = firstname;
+    }
+}
diff --git a/src/Origin.java b/src/Origin.java
new file mode 100644 (file)
index 0000000..72ecd83
--- /dev/null
@@ -0,0 +1,15 @@
+public class Origin {
+    private String country;
+
+    Origin(String country) {
+        setCountry(country);
+    }
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+}
diff --git a/src/Person.java b/src/Person.java
new file mode 100644 (file)
index 0000000..56a02a8
--- /dev/null
@@ -0,0 +1,53 @@
+import javax.swing.*;
+
+public class Person extends JPanel {
+    private Firstname firstname;
+    private Origin origin;
+    private Size size;
+    private Weight weight;
+    private Eye eye;
+
+    Person(Firstname firstname) {
+        setFirstname(firstname);
+    }
+
+    public void setFirstname(Firstname firstname) {
+        this.firstname = firstname;
+    }
+
+    public Firstname getFirstname() {
+        return firstname;
+    }
+
+    public void setOrigin(Origin origin) {
+        this.origin = origin;
+    }
+
+    public Origin getOrigin() {
+        return origin;
+    }
+
+    public void setPersonSize(Size size) {
+        this.size = size;
+    }
+
+    public Size getPersonSize() {
+        return size;
+    }
+
+    public void setWeight(Weight weight) {
+        this.weight = weight;
+    }
+
+    public Weight getWeight() {
+        return weight;
+    }
+
+    public void setEye(Eye eye) {
+        this.eye = eye;
+    }
+
+    public Eye getEye() {
+        return eye;
+    }
+}
diff --git a/src/Size.java b/src/Size.java
new file mode 100644 (file)
index 0000000..0cecada
--- /dev/null
@@ -0,0 +1,24 @@
+
+public class Size {
+    private int max = 240;
+    private int min = 20;
+    private int size;
+
+    Size(int size) {
+        setSize(size);
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        if (validateSize(size)) {
+            this.size = size;
+        } /* FIXME: raise an error */
+    }
+
+    private boolean validateSize(int size) {
+        return (size > max || size < min);
+    }
+}
diff --git a/src/Weight.java b/src/Weight.java
new file mode 100644 (file)
index 0000000..3f2a829
--- /dev/null
@@ -0,0 +1,21 @@
+public class Weight {
+    private int weight;
+
+    Weight(int weight) {
+        setWeight(weight);
+    }
+
+    public int getWeight() {
+        return weight;
+    }
+
+    public void setWeight(int weight) {
+        if (validateWeight(weight)) {
+            this.weight = weight;
+        } /* FIXME: raise an error */
+    }
+
+    private boolean validateWeight(int weight) {
+        return (weight > 0);
+    }
+}