Pangil_aku_Andi

Don't Give Up in Life …

Interface Master


//Superclass berurut
import javax.swing.JOptionPane;
class Master
{
private String judul;
private String publiser;
private String kategori;
private double stok;
public Master (String judul, String publiser, String kategori, double stok){
this.judul = judul;
this.publiser = publiser;
this.kategori = kategori;
this.stok = stok;}
public String toString()
{
return (“Judul\t\t: ” + judul+”\nPubliser\t: “+publiser+”\nKategori\t: “+kategori+”\nStok\t\t: “+stok);
}
}
class cdFilm extends Master
{
private String pemain;
private String sutradara;
public cdFilm(String judul, String publiser, String kategori, double stok,String pemain,String sutradara)
{
super(judul,publiser,kategori,stok);
this.pemain = pemain;
this.sutradara = sutradara;
}
public String toString()
{
return (super.toString()+”\nPemain\t\t: “+pemain+”\nSutradara\t: “+sutradara);
}
}
class cdMusik extends Master
{
private String penyanyi;
private String produser;
public cdMusik(String judul, String publiser, String kategori, double stok,String penyanyi,String produser)
{
super(judul,publiser,kategori,stok);
this.penyanyi = penyanyi;
this.produser = produser;
}
public String toString()
{
return (super.toString()+”\nPenyanyi\t: “+penyanyi+”\nProduser\t: “+produser);
}
}

class latihan3b
{
public static void main(String[] args)
{

cdFilm vcd = new
cdFilm(“cinta”,”oke film”,”Remaja”,500,”Andi”,”Mardianto”);
JOptionPane.showMessageDialog
(null,”FILM\n\nHasilnya adalah : \n”+vcd.toString());

cdMusik cd = new
cdMusik(“Bintang di surga”,”Sony BMG”,”POP”,300,”Peter Pan”,”Andi”);
JOptionPane.showMessageDialog
(null,”MUSIK\n\nHasilnya adalah : \n”+cd.toString());
}
}

//Save dengan format latihan3b

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: