Java
This commit is contained in:
parent
f24050cb7e
commit
975abd0e19
BIN
APL2.1/TP04/Segment/Segment.class
Normal file
BIN
APL2.1/TP04/Segment/Segment.class
Normal file
Binary file not shown.
42
APL2.1/TP04/Segment/Segment.java
Normal file
42
APL2.1/TP04/Segment/Segment.java
Normal file
@ -0,0 +1,42 @@
|
||||
import java.awt.Point;
|
||||
|
||||
public class Segment {
|
||||
private Point start;
|
||||
private Point end;
|
||||
|
||||
public Segment(Point p1, Point p2) {
|
||||
start = p1;
|
||||
end = p2;
|
||||
}
|
||||
|
||||
public Segment(int x1, int y1, int x2, int y2) {
|
||||
start = new Point(x1, y1);
|
||||
end = new Point(x2, y2);
|
||||
}
|
||||
|
||||
public double length() {
|
||||
return Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));
|
||||
}
|
||||
|
||||
public void setStart(Point p) {
|
||||
start = p;
|
||||
}
|
||||
|
||||
public void setStart(int x, int y) {
|
||||
start.x = x;
|
||||
start.y = y;
|
||||
}
|
||||
|
||||
public void setEnd(Point p) {
|
||||
end = p;
|
||||
}
|
||||
|
||||
public void setEnd(int x, int y) {
|
||||
end.x = x;
|
||||
end.y = y;
|
||||
}
|
||||
|
||||
public boolean equals(Segment s2) {
|
||||
return this.start == s2.start && this.end == s2.end;
|
||||
}
|
||||
}
|
BIN
APL2.1/TP04/Segment/TestSegment.class
Normal file
BIN
APL2.1/TP04/Segment/TestSegment.class
Normal file
Binary file not shown.
8
APL2.1/TP04/Segment/TestSegment.java
Normal file
8
APL2.1/TP04/Segment/TestSegment.java
Normal file
@ -0,0 +1,8 @@
|
||||
public class TestSegment {
|
||||
public static void main(String[] args) {
|
||||
Segment s = new Segment(0, 10, 10, 0);
|
||||
Segment s2 = new Segment(0, 10, 10, 0);
|
||||
|
||||
System.out.println(s.equals(s2));
|
||||
}
|
||||
}
|
752
APL2.1/TP04/segment.mdj
Normal file
752
APL2.1/TP04/segment.mdj
Normal file
File diff suppressed because it is too large
Load Diff
2820
APL2.1/TP04/site web.mdj
Normal file
2820
APL2.1/TP04/site web.mdj
Normal file
File diff suppressed because it is too large
Load Diff
9290
APL2.1/TP04/transports.mdj
Normal file
9290
APL2.1/TP04/transports.mdj
Normal file
File diff suppressed because it is too large
Load Diff
3054
APL2.1/TP04/voiture.mdj
Normal file
3054
APL2.1/TP04/voiture.mdj
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user