Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Book {
- private int totalPages, totalChapters;
- private double unitPrice;
- private String title, author, ISBN;
- protected String format = "Paper"; // need to take this value
- private static final double DEFAULT_UNIT_PRICE = 15.00;
- public Book(String title, String author,
- String ISBN, int totalPages, int totalChapters, double unitPrice) {
- this.totalPages = totalPages;
- this.totalChapters = totalChapters;
- this.unitPrice = (unitPrice <= 0) ? DEFAULT_UNIT_PRICE : unitPrice;
- this.title = title;
- this.author = author;
- this.ISBN = ISBN;
- }
- public int getTotalPages() {
- return totalPages;
- }
- public void setTotalPages(int totalPages) {
- this.totalPages = totalPages;
- }
- public int getTotalChapters() {
- return totalChapters;
- }
- public void setTotalChapters(int totalChapters) {
- this.totalChapters = totalChapters;
- }
- public double getUnitPrice() {
- return unitPrice;
- }
- public void setUnitPrice(double unitPrice) {
- this.unitPrice = unitPrice;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public String getAuthor() {
- return author;
- }
- public void setAuthor(String author) {
- this.author = author;
- }
- public String getISBN() {
- return ISBN;
- }
- public void setISBN(String ISBN) {
- this.ISBN = ISBN;
- }
- public String getFormat() {
- return format;
- }
- @Override
- public String toString() {
- return "\nTitle: " + this.title +
- "\nAuthor: " + getAuthor() +
- "\nISBN: " + this.getISBN() +
- "\nNo. of Pages: " + totalPages +
- "\nNo. of Chapters: " + this.getTotalChapters() +
- "\nUnit Price: $" + unitPrice;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement