0% found this document useful (0 votes)
6 views2 pages

Java Book and Golden Edition Classes

Uploaded by

marija.kostovska
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Java Book and Golden Edition Classes

Uploaded by

marija.kostovska
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

class Book {

String title;
String author;
double price;

Book (String title, String author, double price) {


[Link] = title;
[Link] = author;
[Link] = price;
}

Book (Book b) {
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
}

String getTitle() {
return [Link];
}

String getAuthor() {
return [Link];
}

double getPrice() {
return [Link];
}

public String toString() {


return "$" + [Link] + " - " + [Link] + " by " + [Link];
}
}

class GoldenEditionBook extends Book {

private int ratio;

GoldenEditionBook(String title, String author, double price) {


super(title, author, price);
[Link] = 30;
}

GoldenEditionBook(Book b) {
super(b);
[Link] = 30;
}

public void setRatio(int ratio) {


[Link] = ratio;
}

public String toString() {


return "$" + [Link]() + " - " + [Link]() + " by
" + [Link]();
}

private double getIncreasedPrice() {


return [Link]() + [Link]() * [Link] / 100;
}
}

class Inheritance1 {

public static void main(String[] args) {

Book b1 = new Book("Harry Potter", "JK Rowling", 50);


[Link](b1);

GoldenEditionBook gb1 = new GoldenEditionBook(b1);


[Link](gb1);

You might also like