Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class Shape {
- abstract void area();
- }
- class Circle extends Shape {
- public double radius = 5.0 ;
- void area(){
- System.out.println(3.14*radius*radius);
- }
- }
- class Triangle extends Shape {
- public double height = 11.6 ;
- public double base = 7.8 ;
- void area(){
- System.out.println(1.0/2*base*height);
- }
- }
- public class Heart {
- public static void main (String[] args) {
- Shape c1=new Circle();
- Shape c2=new Triangle();
- c1.area();
- c2.area();
- }
- }
Add Comment
Please, Sign In to add comment