Class Book

java.lang.Object
  extended by Book

public class Book
extends java.lang.Object

This Book class represents a collection of pages. The Pages must all be unique and have positive numbers, but they do not need to be consecutive. The adventure should start on Page 1.

Author:
Tim

Constructor Summary
Book()
          Create an empty Book with no Pages
Book(java.lang.String fileName)
          Creates a Book from the text file with the supplied name.
 
Method Summary
 void addPage(Page newPage)
          Add the supplied page.
 int getNumberOfPages()
          Return the total number of Pages
 Page getPage(int pageNumber)
          Return the page with the given Page number.
 void outputBookToHTML(java.lang.String adventureName)
          Creates directory with the suppied name and fills it with an .html representation of the game book
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Book

public Book(java.lang.String fileName)
Creates a Book from the text file with the supplied name. This will only work if the text file exists and has the correct format. Otherwise it will crash with a semi-descriptive error message. An example can be found look like, you can see here
Here is a list of the rules:

Parameters:
fileName - the name of the file to read from.
Throws:
AdventureException - Will crash if no such file exists or if the file has the wrong format

Book

public Book()
Create an empty Book with no Pages

Method Detail

getPage

public Page getPage(int pageNumber)
Return the page with the given Page number. If no such Page exists, the program will crash.

Parameters:
pageNumber - the number of the desired Page
Returns:
the Page with the desired number *
Throws:
AdventureException - Will crash if the Book has no Page with the requested number.

addPage

public void addPage(Page newPage)
Add the supplied page. This method will crash if the supplied Page is null, if it has a page number that is less than one, or if the Book already has a Page with that number.

Parameters:
newPage - the Page to add to the Book
Throws:
AdventureException - Will crash if the supplied Page is null, if it has a page number that is less than one, or if the Book already has a Page with that number.

getNumberOfPages

public int getNumberOfPages()
Return the total number of Pages

Returns:
the number of Pages in this Book

outputBookToHTML

public void outputBookToHTML(java.lang.String adventureName)
Creates directory with the suppied name and fills it with an .html representation of the game book

Parameters:
adventureName - The name for the folder and the .html files.