/**
* A class that maintains information on a book.
* This might form part of a larger application such
* as a library system, for instance.
*
* @author C
* @version 8-12-07
*/
class Book
{
// The fields.
private String author;
private String title;
private int pages;
private String reference;
private int borrowed;
/**
* Set the author and title fields when this object
* is constructed.
*/
public Book(String bookAuthor, String bookTitle, int bookPages)
{
author = bookAuthor;
title = bookTitle;
pages = bookPages;
reference = "0";
borrowed = 0;
}
/**
* this method returns the author of the book
*/
public String getAuthor(){
return author;
}
/**
* this method retirns the title of the book
*/
public String getTitle() {
return title;
}
/**
* this method returns the number of pages in the book
*/
public int getPages()
{
return pages;
}
/**
* this method changes the reference number
*/
public void setRefNumber(String refNumber){
reference = refNumber;
}
/**
* this method returns the reference number
*/
public String getReference()
{
return reference;
}
/**
* this method keeps track of how often the book has been borrowed
*/
public int borrow()
{
borrowed = (borrowed + 1);
return borrowed;
}
/**
* this method changes the reference number
*/
/**
* this method prints the details of the book, title, author and number of pages
* and the reference number and the number of times the book has been borrowed
*/
public void printDetails()
{
System.out.println(" the title of this book is " + title );
System.out.println(" the author of this book is " + author );
System.out.println(" the book has " + pages + " pages");
System.out.println(" the book has been borrowed " + borrowed + " times");
if (reference.length() > 2){
System.out.println(" the reference number for the book is " + reference );
}else{
System.out.println(" zzz ");
}}
// Add the methods here ...
}