1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| public class Points{
private int x, y;
public Points(){}
public Points(int x, int y){
this.x=x;
this.y=y;
}
public void getX(){return this.x;}
public void getY(){return this.y;}
public int setX(int x){this.x=x;}
public int setY(int y){this.y=y}
}
public class Affichable{
private Points points;
public Affichable(){}
public Affichable(int x, int y){
points=new Points(x,y);
}
public Affichable(Points points){
this.points=points;
}
public getPoints(){return this.points;}
public setPoints(Points points){this.points=points;}
public affichable(){
System.out.println("x = "+this.points.getX());
System.out.println("y = "+this.points.getY());
}
}
public class Main{
public static void main(String args[]){
new Affichage(5,-3).affichage();
new Affichage(new Points(5,-3)).affichage();
}
} |
Partager