public class Book { public int getNumChapters() { return this.numChapters; } public Book() { this.chapters = new String[20]; this.numChapters = 0; } public String getTitle() { return this.title; } protected String title; // Needs significant formatting help! public String getAuthor() { return this.author; } protected String author; public String toString() { String stuff = "\"" + this.title + "\" by " + this.author + "\n"; for ( int i = 0; i < numChapters; ++i) { if (chapters[i] != null) { stuff = stuff + " " + (i+1) + ": " + chapters[i] + "\n"; } } return stuff; } int numChapters; public Book(int numChapters) { this.chapters = new String[numChapters]; this.numChapters = 0; } public Book(String author, String title) { this.author = author; this.title = title; this.chapters = new String[20]; this.numChapters = 0; } protected String[] chapters; public void addChapter(String chapterName) throws Exception { if (numChapters >= chapters.length) { throw new Exception(); } chapters[numChapters] = chapterName; numChapters = numChapters + 1; } // Needs more help public String getChapter(int chapterNum) throws Exception { chapterNum=chapterNum - 1; if (chapterNum >= numChapters) { throw new Exception(); } if (chapterNum < 0) { throw new Exception(); } if (chapters[chapterNum] == null) { throw new Exception(); } return chapters[chapterNum]; } }