Untitled
unknown
plain_text
a year ago
1.2 kB
20
Indexable
interface PointGenerique{
void afficher();
void initialiser();
}
class Point2D {
protected double x , y ;// protected afin de laisser un acces securirse a d'autre classe
Point2D(double x1 , double y1){
x = x1;
y = y1;
}
void deplacer(double x1_, double y2_) {
x = x1_ + x;
y = y2_+ y;
}
void afficher() {
System.out.println("x : "+x+ " et :"+y);
}
void initialiser() {
x=0;
y=0;
}
public String toString() {
return ("x : " + x +" et y : " +y );
}
}
class Point2DAvecCouleur extends Point2D {
private String Couleur;
Point2DAvecCouleur(double x1, double y1,String Cooleur) {
super(x1, y1);
Couleur=Cooleur;
}
void afficher() {
super.afficher();
System.out.println("sa couleur : " + Couleur );
}
String getCouleur(){
return ("La couleur du point : " + Couleur );
}
void setCouleur(String nouvellecouleur){
Couleur = nouvellecouleur;
}
}
public class TestPoint2D5 {// la ou je réalise ma test
public static void main(String[] args) {
Point2DAvecCouleur A = new Point2DAvecCouleur(5,5,"Miam");
A.afficher();
A.getCouleur();
A.setCouleur("PIMENTO");
A.afficher();
}
}
Editor is loading...
Leave a Comment