Sunday, 19 September 2010

Types of book

Now in a library, book can be loanable and reference book.

So we can extend book to loanable providing the function which tells whether the book is loanable or not.

public class LoanBook extends Book implements Loanable
{
 public LoanBook (String title, String author,  double price, int category, int subCategory)
 {
  super(title,author,price,category,subCategory);
 }

 public boolean canLoan()
 {
  return true;
 }

 public String details ()
 {
  return "Loan: "+super.getDetails();
 }

 public String toString()
 {
  return super.toString() + "--Loanable Book";
 }

    public boolean isLoanable()
    {
        return true;
    }
}

No comments:

Post a Comment