You are on page 1of 4

Nama : Juliansyah Darmawan

NPM : 14402426
Kelas : MIF K-42/14
1. Class Diagram

Catatan : Tambahan Set untuk mengisikan nilai atribute di kelas tersebut.
Get untuk mengambil isi atribute di kelas tersebut.
Disoal ada kesalahan coding yaitu saat hardwarebook h = new
hardwarebook()
Error karena tidak ada class hardwarebook
2. book.java
public class book{
int price, pages;
public book(){

} public int getPrice(){ return this. this. int price.java public class softwarebook extends book{ String softwareName. this.softwareName = softwareName. this. } public String getSoftwareVersion(){ return this.softwareVersion = "Software Version Has Not been set". this. softwareVersion.println("Pages of book is "+getPages()).pages = 0.softwareVersion. this.price = price. String softwareVersion. } } softwarebook. int pages){ super(price. public softwarebook (){ super(). } public void setSoftwareName(String softwareName){ this.softwareName = softwareName.price = 0.price. this.pages = pages. this.pages. pages).softwareVersion = softwareVersion. } public book(int price. } public softwarebook(String softwareName.price = price.out. System.softwareName. } public String getSoftwareName(){ return this. } . int pages){ this. } public int getPages(){ return this. } public void show(){ System.pages = pages.out. } public void setPrice(int price){ this. } public void setPages(int pages){ this.println("Price of book is "+getPrice()).softwareName = "Software Has Not been set".

softwareName = "Author Has Not been set". this. this. } public CPlus(String author. System.title. pages).println("Author is "+getAuthor()).author = author. } public void showData(){ showDetail().java public class CPlus extends softwarebook{ String author. System.println("Software Version is "+getSoftwareVersion()). } public String getAuthor(){ return this. } public void setAuthor(String author){ this.softwareVersion = "Title Has Not been set".softwareVersion = softwareVersion. System. String softwareVersion. .out. System. public void setSoftwareVersion(String softwareVersion){ this. this. } } BookApp. String title. int pages){ super(softwareName.author = author. } public void showDetail(){ show(). this.println("TItle is "+getTitle()).println("Software Name is "+getSoftwareName()).out. public CPlus (){ super().out. int price.out. softwareVersion.java public class BookApp{ .author. price. } } CPlus. } public String getTitle(){ return this. } public void setTitle(String title){ this. String softwareName. title.title = title.title = title.

c1.setAuthor("Darmawan"). } } .setSoftwareName("ZRZ Software Book"). c1.showData().setTitle("Easy way to learn java")."OOP BOOK".setPages(50). CPlus c2 = new CPlus("Juliansyah".setSoftwareVersion("V-02"). "V- 01". "ZRZ Application". c1.setPrice(200000). c1. c1. 150). 150000.showData(). c2. public static void main(String args[]){ CPlus c1 = new CPlus(). c1. c1.