Files
Java_Dev/03-SOURCES/Cercle.java
Christian Cunat-Brulé f55475a23f CCB Premier Import
2018-07-23 10:52:48 +02:00

31 lines
625 B
Java

class Cercle
{ class Centre // définition interne a Cercle
{ public Centre (int x, int y)
{ this.x = x ; this.y = y ;
}
public void affiche()
{ System.out.println (x + ", " + y) ;
}
class CentreCentre {
}
private int x, y ;
}
public Cercle (int x, int y, double r)
{ c = new Centre (x, y) ;
this.r = r ;
}
public void affiche ()
{ System.out.print ("cercle de rayon " + r + " de centre ") ;
c.affiche() ;
}
public void deplace (int dx, int dy)
{ c.x += dx ; c.y += dy ; // ici, on a bien acces à x et y
}
private Centre c ;
private double r ;
}