BlackBoY_

VolumeBalok

Jul 1st, 2021 (edited)
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Tugasnya;
  2.  
  3. import Tugasnya.RumusVolumeBalok2;
  4.  
  5. interface VolumeBalok{
  6.     public void namaBarang();
  7. }
  8.  
  9. abstract class VolumeBalok2{
  10.     public abstract void namaBarang();
  11.     public abstract void rumus(int p, int l, int t);
  12. }
  13.  
  14. class book implements VolumeBalok, RumusVolumeBalok2{
  15.  
  16.     @Override
  17.     public void namaBarang() {
  18.         System.out.println("Nama Barang : Buku");
  19.     }
  20.  
  21.     @Override
  22.     public void rumus(int p, int l, int t) {
  23.         int hasil = p*l*t;
  24.         System.out.println("Volume Barang : "+hasil+" CM3");
  25.     }
  26.    
  27. }
  28.  
  29. class basket extends VolumeBalok2{//RumusVolumeBalok2{
  30.    
  31.     public void namaBarang(){
  32.         System.out.println("Nama Barang : Keranjang");
  33.     }
  34.    
  35.     @Override
  36.     public void rumus(int p, int l, int t) {
  37.         int hasil = p*l*t;
  38.         System.out.println("Volume Barang : "+hasil+" CM3");
  39.     }
  40. }
  41.  
  42. class main{
  43.     public static void main(String[] args) {
  44.         book buku = new book();
  45.         buku.namaBarang();buku.rumus(20, 10, 5);
  46.         basket keranjang = new basket();
  47.         keranjang.namaBarang();keranjang.rumus(80, 50, 60);
  48.     }
  49. }
Add Comment
Please, Sign In to add comment