Bonsoir
J'ai un exer en Java concernant les classes abstraites..J'ai crée des classes: lignes, rectangle, triabgle, carré qui sont des sous-classes d'une classe-mère FormeGéométrique et une classe PointXY. Mais la méthode main je ne sais pas comment la faire marcher.. Merci d'avance!
Voila mon code:
Code://classe 1 public class PointXY { protected double x; protected double y; public PointXY (double x, double y){ this.x=x; this.y=y; } public double getx(){ return x; } public double gety(){ return y; } public void setx(double x){ this.x=x; } public void sety(double y){ this.y=y; } public void deplace(double dx, double dy){ x+=dx; y+=dy; } } //classe 2 public class Triangle extends FormeGeometrique { protected double x; protected double y; public double Surface(PointXY centre, PointXY position) { double Surface = (x*y)/2; return Surface; } public double Perimetre(PointXY centre, PointXY position) { double Perimetre = (x+y); return Perimetre; } } //classe 3 public class Rectangle extends FormeGeometrique { private double x; private double y; public double Surface(PointXY centre, PointXY position) { double Surface= x*y; return Surface; } public double Perimetre(PointXY centre, PointXY position) { double Perimetre= 2*(x+y); return Perimetre; } //classe 4 public class Carré extends Rectangle{ protected double x; protected double y; public double Surface(PointXY centre, PointXY position) { return x*x; } public double Perimetre(PointXY centre, PointXY position) { return x+x; } } //classe 5 public class Cercle extends FormeGeometrique{ protected double x; protected double y; public double Surface(PointXY centre, PointXY position) { return 3.14*x*x/2; } public double Perimetre(PointXY centre, PointXY position) { return 2*3.14*x; } }
-----