"depot M213"

This commit is contained in:
JunkJumper
2020-05-03 14:24:13 +02:00
parent 1408744dbb
commit e5983242c6
136 changed files with 161184 additions and 0 deletions

BIN
TD1/TD1.pdf Executable file

Binary file not shown.

7
TD1/src/HelloWorld.java Executable file
View File

@ -0,0 +1,7 @@
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("\nHelloWord ! :)");
}
}

100
TD1/src/point/Point.java Executable file
View File

@ -0,0 +1,100 @@
package point;
public class Point
{
//attributs
public double x;
public double y;
//constructeurs
public Point()
{
x = 0;
y = 0;
}
public Point(double x, double y)
{
this.x = x;
this.y = y;
}
//methode d'instance
public String toString()
{
return "(X = " + this.x + " - Y = " + this.y + ")";
}
public double getDistance(Point p)
{
double result;
result = Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
return result;
}
//accesseur en lecture
public double getX() {
return x;
}
public double getY() {
return y;
}
public Point projX()
{
return new Point(this.x, 0.);
}
public Point projY()
{
return new Point(0., this.y);
}
public boolean equals (Object obj)
{
Point p = (Point)obj;
if (this.x == p.x && this.y == p.y)
return true;
else return false;
}
public Point clone()
{
return new Point(this.x, this.y);
}
public void getLocation()
{
System.out.println("x = " + this.x + " , y = " + this.y + ".");
}
public void setLocation(Point p)
{
p.x = this.x;
p.y = this.y;
}
public void setLocation(double x, double y)
{
x = this.x;
y = this.y;
}
public void translate(int dx, int dy)
{
this.x = this.x+dx;
this.y = this.y+dy;
}
//getters and setters
public void setX(double x) {
this.x = x;
}
public void setY(double y) {
this.y = y;
}
}

14
TD1/src/point/PointTest.java Executable file
View File

@ -0,0 +1,14 @@
package point;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class PointTest {
@Test
void test() {
fail("Not yet implemented");
}
}

76
TD1/src/point/TestPoint.java Executable file
View File

@ -0,0 +1,76 @@
package point;
public class TestPoint {
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);
System.out.println(" O = " + O.toString());
System.out.println(" I = " + I.toString());
System.out.println(" J = " + J.toString());
System.out.println(" A = " + A.toString());
System.out.println(" B = " + B.toString());
System.out.println(" C = " + C.toString());
System.out.println(" D = " + D.toString());
System.out.println("La distance O - I est de " + O.getDistance(I));
System.out.println("La distance O - J est de " + O.getDistance(J));
System.out.println("La distance J - I est de " + J.getDistance(I));
System.out.println("La distance A - B est de " + A.getDistance(B));
System.out.println("La distance B - A est de " + B.getDistance(A));
System.out.println("La distance A - C est de " + A.getDistance(C));
System.out.println("La distance C - A est de " + C.getDistance(A));
System.out.println("La distance O - D est de " + O.getDistance(D));
System.out.println("Le getX de A est " + A.getX());
System.out.println("Le getY de A est " + A.getY());
System.out.println("Le ProjX de A est " + A.projX());
System.out.println("Le ProjY de A est " + A.projY());
System.out.println("Le ProjX de B est " + B.projX());
System.out.println("Le ProjY de B est " + B.projY());
System.out.println("Le ProjX de O est " + O.projX());
System.out.println("Le ProjY de O est " + O.projY());
System.out.println("Le ProjX de I est " + I.projX());
System.out.println("Le ProjY de I est " + I.projY());
System.out.println("Le ProjX de J est " + J.projX());
System.out.println("Le ProjY de J est " + J.projY());
System.out.println(A.equals(A));
System.out.println(O.equals(O));
System.out.println(I.equals(J));
System.out.println(J.equals(I));
System.out.println(B.equals(B));
System.out.println(C.equals(C));
/*A.setLocation(5., 2.);
B.setLocation(3., -2.);
C.setLocation(6., 5.);
O.setLocation(-5., 8.);*/
A.translate(5, 2);
B.translate(3, -2);
C.translate(6, 5);
O.translate(-5, 8);
System.out.println(A.toString());
System.out.println(B.toString());
System.out.println(C.toString());
System.out.println(O.toString());
}
}