diff options
Diffstat (limited to 'semestre 4/java/tme/tp1/Segment.java')
| -rw-r--r-- | semestre 4/java/tme/tp1/Segment.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/semestre 4/java/tme/tp1/Segment.java b/semestre 4/java/tme/tp1/Segment.java new file mode 100644 index 0000000..6529279 --- /dev/null +++ b/semestre 4/java/tme/tp1/Segment.java @@ -0,0 +1,17 @@ +public class Segment { + private int x; + private int y; + + public Segment(int x, int y) { + this.x = x; + this.y = y; + } + + public int longueur() { + return x < y ? y - x : x - y; + } + + public String toString() { + return String.format("Segment [%d, %d]", x, y); + } +} |
