Refonte du repo
This commit is contained in:
49
src/TD3/segment/Segment.java
Normal file
49
src/TD3/segment/Segment.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package segment;
|
||||
import point.Point;
|
||||
|
||||
public class Segment {
|
||||
|
||||
public Point origine;
|
||||
public Point extremite;
|
||||
|
||||
public Segment(Point p1, Point p2) throws Throwable
|
||||
{
|
||||
if(p1.equals(p2)) throw new Throwable("Les points sont confondus !");
|
||||
this.origine = p1;
|
||||
this.extremite = p2;
|
||||
}
|
||||
|
||||
public boolean equals(Object B)
|
||||
{
|
||||
Segment s = (Segment) B;
|
||||
return this.origine.equals(s.origine)&&(this.extremite.equals(s.extremite)) || this.origine.equals(extremite)&&(this.extremite.equals(s.origine));
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "[" + origine + " - " + extremite + "]";
|
||||
}
|
||||
|
||||
/*public Object clone() throws Throwable
|
||||
{
|
||||
return new Segment((Point)this.origine.clone, (Point)this.extremite.clone);
|
||||
}*/
|
||||
|
||||
public double longueur()
|
||||
{
|
||||
return origine.getDistance(extremite);
|
||||
}
|
||||
|
||||
public Segment projX() throws Throwable
|
||||
{
|
||||
if(origine.projX().equals(extremite.projX())) throw new Throwable("Les points projetes sont confondus !");
|
||||
return new Segment(origine.projX(), extremite.projX());
|
||||
}
|
||||
|
||||
public Segment projY() throws Throwable
|
||||
{
|
||||
if(origine.projY().equals(extremite.projY())) throw new Throwable("Les points projetes sont confondus !");
|
||||
return new Segment(origine.projY(), extremite.projY());
|
||||
}
|
||||
|
||||
}
|
||||
43
src/TD3/segment/TestSegment.java
Normal file
43
src/TD3/segment/TestSegment.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package segment;
|
||||
import point.Point;
|
||||
|
||||
public class TestSegment {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Point O = new Point();
|
||||
Point I = new Point(1.0, 0.0);
|
||||
Point J = new Point(0.0, 1.0);
|
||||
Point A = new Point(1.0, 3.5);
|
||||
Point B = new Point(8.0, 20.0);
|
||||
Point C = new Point(-2.0, 3.0);
|
||||
Point D = new Point(1.0, 1.0);
|
||||
|
||||
Segment AB = null;
|
||||
Segment BC = null;
|
||||
Segment OI = null;
|
||||
Segment OJ = null;
|
||||
Segment OD = null;
|
||||
//Segment AA = null;
|
||||
try {
|
||||
AB = new Segment(A, B);
|
||||
BC = new Segment(B, C);
|
||||
OI = new Segment(O, I);
|
||||
OJ = new Segment(O, J);
|
||||
OD = new Segment(O, D);
|
||||
//AA = new Segment(A, A);
|
||||
} catch (Throwable t) {
|
||||
System.out.println("Erreur : " + t);
|
||||
}
|
||||
|
||||
System.out.println(OI.toString());
|
||||
System.out.println(OJ.toString());
|
||||
System.out.println(AB.toString());
|
||||
System.out.println(BC.toString());
|
||||
System.out.println(OD.toString());
|
||||
//System.out.println(AA.toString());
|
||||
|
||||
System.out.println("Hello world !");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user