book.java

来自「ssd3的教程 是我们老师给我们的 纯英文 有兴趣的可以」· Java 代码 · 共 73 行

JAVA
73
字号
/*!Begin Snippet:file*/
/**
 * This class models a book. It extends {@link CatalogItem} and
 * adds the following information:
 * <ol>
 * <li>the author of the book, a <code>String</code></li>
 * <li>the number of pages in the book, an <code>int</code></li>
 * </ol>
 *
 * @author author name
 * @version  1.0.0
 * @see CatalogItem
 */
public class Book extends CatalogItem  {

	/* Author of the book.*/
	private String  author;

	/* Number of pages in the book.*/
	private int  numberOfPages;

	/**
	 * Constructs a <code>Book</code> object.
	 *
	 * @param initialCode  the code of the book.
	 * @param initialTitle  the title of the book.
	 * @param initialYear  the year the book was published.
	 * @param initialAuthor  the author of the book.
	 * @param initialNumberOfPages  the number of pages in the book.
	 */
	public Book(String initialCode, String initialTitle,
	 		int initialYear, String initialAuthor,
			int initialNumberOfPages) {

		super(initialCode, initialTitle, initialYear);

		author = initialAuthor;
		numberOfPages = initialNumberOfPages;
	}

	/**
	 * Returns the author of this book.
	 *
	 * @return  the author of this book.
	 */
	public String  getAuthor()  {

		return  author;
	}

	/**
	 * Returns the number of pages in this book.
	 *
	 * @return  the number of pages in this book.
	 */
	public int  getNumberOfPages()  {

		return  numberOfPages;
	}

	/**
	 * Returns the string representation of this book.
	 *
	 * @return  the string representation of this book.
	 */
	public String toString()  {

		return  super.toString() + "_" + getAuthor() + "_"
		        + getNumberOfPages();
	}
}
/*!End Snippet:file*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?