CODIGO1 figura.java
public interface Figura {
abstract double area();
abstract double perimetro();
}
CODIGO2
circulo.java
public class Circulo implements Figura {
public double radio;
public static double PI=3.1416;
public double area() { return PI*radio*radio; }
public double perimetro() { return 2*PI*radio; }
}
CODIGO 3
demoFig
public class demoFig {
public demoFig() {
}
public static void main(String args[])
{
Circulo circle=new Circulo();
circle.radio=15;
System.out.println("Area= "+circle.area());
}
}
No hay comentarios:
Publicar un comentario