Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * A class that maintains information on a book.
- * This might form part of a larger application such
- * as a library system, for instance.
- *
- * @author Rifqi Mukti Wicaksana
- * @version 29.09.2017
- */
- class Book
- {
- // The fields.
- private String author;
- private String title;
- private String refNumber;
- private int pages;
- /**
- * Set the author and title fields when this object
- * is constructed.
- */
- public Book(String bookAuthor, String bookTitle, String bookrefNumber, int bookPages)
- {
- author = bookAuthor;
- title = bookTitle;
- pages = bookPages;
- refNumber = "";
- }
- public String getAuthor()
- {
- return author;
- }
- public String getTitle()
- {
- return title;
- }
- public int getPages()
- {
- return pages;
- }
- public String getRefNumber()
- {
- return refNumber;
- }
- public void setRefNumber(String refNumber)
- {
- this.refNumber = refNumber;
- }
- public void printAuthor()
- {
- System.out.println(author);
- }
- public void printTitle()
- {
- System.out.println(title);
- }
- public void printDetails()
- {
- String refNumPrint = refNumber;
- System.out.println("Title: " + title + ",Author: " + author + ",Pages: " + pages);
- if(refNumPrint.length() < 0)
- {
- refNumPrint = "ZZZ";
- }
- System.out.println("Reference number: " + refNumPrint);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement