-
-
-
-
-
-
-
-
abstract class Shape {
int a,b;
public Shape(int aa, int bb) {a=aa; b=bb;}
abstract public double area();
}
class Rectangle extends Shape {
public Rectangle(int aa, int bb) {super(aa,bb);}
public double area() {return a*b;}
}
class Triangle extends Shape {
public Triangle(int aa, int bb) {super(aa,bb);}
public double area() {return a*b/2;}
}
public class XXK3 {
public static void main(String[] args) {
Shape x,y;
x=new Rectangle(10,20);
y=new Triangle(10,15);
System.out.println(x.area()+", "+y.area());
}
}200.1, 75.1200.0, 75.0
-
-