Skip to content

Instantly share code, notes, and snippets.

@Klamin220
Created March 6, 2019 15:30
Show Gist options
  • Select an option

  • Save Klamin220/8fcc63e71f8d47ea6d5bf15e4527f61f to your computer and use it in GitHub Desktop.

Select an option

Save Klamin220/8fcc63e71f8d47ea6d5bf15e4527f61f to your computer and use it in GitHub Desktop.
package td4;
public class Point {
double x,y;
Point o;
String nom;
Point(String nom){
x=0;
y=0;
this.nom=nom;
nom="Origine par defaut";
}
Point(double x,double y, String nom){
this.x=x;
this.y=y;
this.nom=nom;
}
double getAbs(){
return(x);
}
double getOrd(){
return(y);
}
void setAbs(double x) {
this.x=x;
}
void setOrd(double x) {
y=x;
}
double getX() {
return(getAbs()-o.getAbs()); // On ne peut pas mettre o.x à la place de o.getAbs() car elle est statique
}
double getY() {
return(getAbs()-o.getOrd()); // Idem
}
boolean pegX(Point x) {
return(getAbs()<=x.getAbs());
}
boolean pegY(Point x) {
return(getOrd()<=x.getOrd());
}
void translate(double x, double y) {
this.x=this.x+x;
this.y=this.y+y;
}
void symetrie() {
translate(2*getX(),-2*getY());
}
void info() {
System.out.println(nom+"("+x+","+y+")");
}
void setOrg(Point p) {
o=p;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment