Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Book
- {
- private String author;
- private String title;
- public int pages;
- public String refNumber;
- int borrowed;
- boolean courseText;
- public Book (String bookAuthor, String bookTitle, int bookPages, boolean newCourseText)
- {
- author = bookAuthor;
- title = bookTitle;
- pages = bookPages;
- refNumber = "";
- courseText = newCourseText;
- }
- public String getAuthor ( ) {
- return author;
- }
- public String getTitle ( ) {
- return title;
- }
- public int getPages ( ) {
- return pages;
- }
- public String refNumber ( ) {
- return refNumber;
- }
- public void setRefNumber(String ref) {
- if (ref.length() >= 3)
- {
- refNumber = ref;
- }
- else
- {
- System.out.println("##################################################");
- System.out.println("Reference number cannot be less than 3 characters!");
- System.out.println("##################################################");
- }
- }
- public String getRefNumber ( ) {
- return refNumber;
- }
- public void increaseborrow() {
- borrowed = borrowed + 1;
- }
- public int getBorrowed() {
- return borrowed;
- }
- public boolean isCourseText() {
- return courseText;
- }
- public void printBook()
- {
- System.out.println("***********************************");
- System.out.println("Author: " + author + ".");
- System.out.println("Title: " + title + ".");
- System.out.println("Pages: " + pages + ".");
- if (refNumber.length() >= 3) {
- System.out.println("Ref No.: " + refNumber + ".");
- } else {
- System.out.println("No reference number!");
- }
- if (borrowed == 0) {
- System.out.println(title + " hasn't been borrowed yet.");
- }
- else if (borrowed == 1)
- {
- System.out.println(title + " has been borrowed " + borrowed + " time.");
- }
- else {
- System.out.println(title + " has been borrowed " + borrowed + " times.");
- }
- System.out.println("Text book on a course: " + courseText + ".");
- System.out.println("***********************************");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment