abstract class Shapeok{
abstract double area();}
class Circle extends Shapeok{
public float r;
Circle(float r)
{
this.r=r;
}
double area()
{
return 3.14*r*r;
}
}
class Rectang extends Shapeok{
public float width,height;
Rectang(float width,float height) {
// TODO Auto-generated constructor stub
this.width=width;
this.height=height;
}
double area()
{
return width*height;
}
}
public class Shape {
/**
* @param args
*/
public static void main(
String[] args) {
// TODO Auto-generated method stub
double areatotal=0;
Shapeok[] shapes=new Shapeok[2];
shapes[0]=new Circle(1);
shapes[1]=new Rectang(1, 2);
for (int i = 0; i < shapes.length; i++) {
areatotal+=shapes[i].area();
System.out.print(areatotal);
}
}
}
abstract double area();}
class Circle extends Shapeok{
public float r;
Circle(float r)
{
this.r=r;
}
double area()
{
return 3.14*r*r;
}
}
class Rectang extends Shapeok{
public float width,height;
Rectang(float width,float height) {
// TODO Auto-generated constructor stub
this.width=width;
this.height=height;
}
double area()
{
return width*height;
}
}
public class Shape {
/**
* @param args
*/
public static void main(
String[] args) {
// TODO Auto-generated method stub
double areatotal=0;
Shapeok[] shapes=new Shapeok[2];
shapes[0]=new Circle(1);
shapes[1]=new Rectang(1, 2);
for (int i = 0; i < shapes.length; i++) {
areatotal+=shapes[i].area();
System.out.print(areatotal);
}
}
}