Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Tugasnya;
- import Tugasnya.RumusVolumeBalok2;
- interface VolumeBalok{
- public void namaBarang();
- }
- abstract class VolumeBalok2{
- public abstract void namaBarang();
- public abstract void rumus(int p, int l, int t);
- }
- class book implements VolumeBalok, RumusVolumeBalok2{
- @Override
- public void namaBarang() {
- System.out.println("Nama Barang : Buku");
- }
- @Override
- public void rumus(int p, int l, int t) {
- int hasil = p*l*t;
- System.out.println("Volume Barang : "+hasil+" CM3");
- }
- }
- class basket extends VolumeBalok2{//RumusVolumeBalok2{
- public void namaBarang(){
- System.out.println("Nama Barang : Keranjang");
- }
- @Override
- public void rumus(int p, int l, int t) {
- int hasil = p*l*t;
- System.out.println("Volume Barang : "+hasil+" CM3");
- }
- }
- class main{
- public static void main(String[] args) {
- book buku = new book();
- buku.namaBarang();buku.rumus(20, 10, 5);
- basket keranjang = new basket();
- keranjang.namaBarang();keranjang.rumus(80, 50, 60);
- }
- }
Add Comment
Please, Sign In to add comment