Created
March 6, 2019 15:30
-
-
Save Klamin220/8fcc63e71f8d47ea6d5bf15e4527f61f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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