public class Book
extends java.lang.Object
Constructor and Description |
---|
Book()
Constructor for objects of class Book with default values.
|
Book(java.lang.String title,
java.lang.String author,
int pages)
Constructor to set instance variables to the parameters.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAuthor()
Returns the author of the book.
|
int |
getPages()
Returns the value of the pages data field.
|
java.lang.String |
getTitle()
Returns the title of the book.
|
void |
setAuthor(java.lang.String author)
Updates the author of the book.
|
void |
setPages(int pages)
Updates the number of pages in the book which must be a positive number.
|
void |
setTitle(java.lang.String title)
Updates the title of the book.
|
java.lang.String |
toString()
Return the book information with title, author and pages.
|
public Book()
public Book(java.lang.String title, java.lang.String author, int pages)
title
- the title of the bookauthor
- the author of the bookpages
- the number of pages in the bookpublic java.lang.String getAuthor()
public int getPages()
public java.lang.String getTitle()
public void setAuthor(java.lang.String author)
author
- the author of the bookpublic void setPages(int pages)
pages
- the number of pages in the bookpublic void setTitle(java.lang.String title)
title
- the title of the bookpublic java.lang.String toString()
toString
in class java.lang.Object