tamarawriter

Java - Polmorfisme - Main

Jun 10th, 2020
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. package Polimorfisme;
  2. /**
  3.  *
  4.  * @author Ra
  5.  */
  6. public class Main {
  7.     public static void main(String[] args) {
  8.         BangunDatar bd = new BangunDatar();
  9.         Persegi p = new Persegi(5);
  10.         Lingkaran ling = new Lingkaran(7);
  11.        
  12.         //memanggil method luas dan keliling
  13.         bd.luas();
  14.         bd.keliling();
  15.        
  16.         System.out.println("Luas Persegi = "+p.luas());
  17.         System.out.println("Keliling Persegi = "+p.keliling());
  18.         System.out.println("Luas Lingkaran = "+ling.luas());
  19.         System.out.println("Keliling Lingkaran = "+ling.keliling());
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment