// Arup Guha
// 11/9/2009
// Solution to AP Computer Science Class: Book

import java.util.*;

public class Book {

	// Instance variables.
	private String author;
	private String title;
	private int pages;
	private int curpage;



	// Creates a book object with the given information, setting
	// the current page to 0.
	public Book(String writer, String thistitle, int numpages) {
		author = writer;
		title = thistitle;
		pages = numpages;
		curpage = 0;
	}

	// Advances the bookmark by numpages. If there are fewer pages
	// to read, then the curpage is set to the last page.
	public void read(int numpages) {
		
		// If you've read too many pages, just set the current page to the end.
		if (curpage + numpages > pages)
			curpage = pages;
			
		// Otherwise, this is how many pages you've read.
		else
			curpage += numpages;
	}

	// Creates a new Book object with the same author as this Book
	// the same title with “II” appended to it, with numpages
	// number of pages and sets the bookmark to 0. This new object
	// is returned.
	public Book makeSequel(int numpages) {
		return new Book(author, title+"II", numpages);
	}

	// Returns the number of pages left to read in this Book.
	public int pagesLeft() {
		return pages - curpage;
	}

	// Returns the number of pages in the Book.
	public int getNumPages() {
		return pages;
	}
	
	// Returns the author - this had to be added because we need to access
	// this from RunBook.
	public String getAuthor() {
		return author;
	}
	
	// Returns the title - this had to be added because we need to access
	// this from RunBook.
	public String getTitle() {
		return title;
	}

}