Guest User

Untitled

a guest
Oct 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. abstract class Shape {
  2.     abstract void area();
  3.  
  4. }
  5.  
  6. class Circle extends Shape {
  7.     public double radius = 5.0 ;
  8.    
  9.     void area(){
  10.         System.out.println(3.14*radius*radius);
  11.     }
  12. }
  13.  
  14. class Triangle extends Shape {
  15.     public double height = 11.6 ;
  16.     public double base = 7.8 ;
  17.     void area(){
  18.         System.out.println(1.0/2*base*height);
  19.     }
  20. }
  21.  
  22. public class Heart {
  23.     public static void main (String[] args) {
  24.    
  25.     Shape c1=new Circle();
  26.     Shape c2=new Triangle();
  27.     c1.area();
  28.     c2.area();
  29.    
  30.    
  31.     }
  32.    
  33. }
Add Comment
Please, Sign In to add comment