aboutsummaryrefslogtreecommitdiff
path: root/semestre 4/java/tme/tp1/Segment.java
blob: 652927912eb82b8f5e8970fc56c28d109c2d3f6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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);
    }
}