apres execution de mon code FormeGeometrique1
x et y sont a zero comment corriger mon probleme
FormeGeoetrique1.java
Rectangle.java
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 abstract class FormeGeometrique1 {int x,y; void deplacer(int x,int y) {this.x=x; this.y=y;} void afficherPosition() {System.out.println("x="+x+" y="+y);} abstract double surface(); public static void main(String args[]) { Rectangle r=new Rectangle(45,12,23,11); r.afficherPosition(); System.out.println(r.surface()); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 class Rectangle extends FormeGeometrique1 {int x;int y; float a;float b; Rectangle(int x,int y,float a,float b) { this.x=x;this.y=y; this.a=a;this.b=b;} void deplacer() {super.deplacer(x,y);} double surface() {return a*b;} }
Partager