    /*
     * D.java, 
     * Short for dungeons and dragons. 
     * A silly high fantasy interactive fictiony thing. 
     * November 2015
     * @author MHowse
     */

    package d; 
    
    
   
/**
 * Import graphics and swing libraries.
 */
import java.awt.Graphics.*;
import javax.swing.*;

    /**
     * Declare class.
     */
public class D {
  
    /**
     * Declare and initialize class variables
     */
  protected static int [] history = new int [10]; 
//keeps track of what pages have been visited in what order. 
  protected int pageNumber;
 
  //current options to consider before continuing,
  //make page object in binary tree? option 1/2 == branch right left,
  //back == go up tree  towards root. or keep history array?
  //history array allows for keeping track of dead end-backtracking adventures better
 protected  static int pageCount; // how many pages through story we are
  protected  static int currentPage = history[pageCount]; //one currently on. 
  protected  static int prevoiusPage = history[pageCount] -1;
  protected static int pageNumberValue;
  protected static String one= "This story";
  protected static String two= "This story";
  protected static String three= "This story";
  protected static String four= "This story";
  /**
   * Turns back  page once user has made decision. 
   * Works out which page was up previous to the current one, and 
   * tells pageTurn to turn to that one. 
   * @param evt 
   * @return void
   */
  public static void backPage(){
    pageTurn(prevoiusPage);
    
  }
  
  /**
   * Turns the next page once user has made decision.
   * Decides which page is turned to.
   * Passes decision to page turning method.
   * @param int n which indicates users decision 
   * @return void
   */
  public static void nextPage(int n){
    //If first option n will be one, if second, will be two.  
    String page = Integer.toString(history[pageNumberValue]); 
//find current page in array
    page = page+ n; //option 1 = odd numbers; 
    //option 2 = even numbers
    pageTurn(Integer.parseInt(page)); //change pages; 
  }
  
  /**
   * pageTurn, keeps variables in correct state and calls 
   * the methods required to make the page turn come into effect.
   * @param int a : a is the page to be turned to 
   */
  public  static void pageTurn( int a ){
    pageCount++;
    history[pageCount] = pageNumberValue; //record
    pageNumberValue = a; //set check value
    //call new page;
    switch(a){
      case 1: 
        page1();
        break;
      case 2: 
        page2();
        break;
      case 3:
        page3();
        break;
      case 4:
        page4();
        break;
      default:
             
    }
  }
  
  /**
   *  Accessor method that says which page user is currently on. 
   * In string form.
   * @return string that is the page.
   */
  public static String getPage(){
    String p = Integer.toString(currentPage);
    return p;
  }
  /**
   *  Accessor method that says which page user is currently on. 
   * In int form
   * @return int  that is the page.
   */
  public   static int currentPage(){
    return history[pageCount];
  }
  
  /**
   *  Accessor method that says which page user was  previuosly on. 
   * In int form.
   * @return in that is the page number.
   */
  public  static int prevoiusPage(){
    if (pageCount ==0){
      return pageCount;
    } 
    return history[pageCount-1];
  }
  
  /**
   * Initial page loaded thing. 
   */
  public static void prolouge(){
    one = "This is a dnd inspired roll your own adventure interactive fiction";
    gui.drawPage(one,two,three,four);
    history[0] = 0;
    pageCount = 0;
  }
  
  /**
   *  method for the first page,initialise the string that will be the page text
   * then send it to the gui to be displayed. 
   */
  public static void page1 (){ 
    //set page text field to the page. 
    one = "This is the begining of the story "; 
    two= "One time a witch walked a path.";
    three= "she came to a fork in the path, should she go left or right?";
    four = "click option 1 to go left, option 2 to go right.";
    gui.drawPage(one,two,three,four);
    gui.illustrate(3);
    //add some ascii art. 
  }
   /**
   *  method for the second page,initialise the string that will be the page
   * text
   * then send it to the gui to be displayed. 
   */
  public static void page2 (){
    String derp ="derp";
    //gui.displayString(derp);
  }
   /**
   *  method for the third page,initialise the string that will be the page 
   * text
   * then send it to the gui to be displayed. 
   */
  public static void page3(){
    
  }
   /**
   *  method for the fourth page,initialise the string that will be the page text
   * then send it to the gui to be displayed. 
   */
  public static void page4(){
    
  }
}//end class

       
@@ -1304,16 +1304,108 @@
 tory%22;%0D%0A
+  protected static String five=%22this story%22;%0D%0A  protected static String six =%22This story%22;%0D%0A
   /**%0D%0A 
@@ -3819,32 +3819,43 @@
 e,two,three,four
+, five, six
 );%0D%0A    history%5B
@@ -4172,39 +4172,44 @@
 two=
+ 
  %22On
+c
 e 
-time a witch walked a pat
+upon a time there was a witc
 h.%22;
@@ -4226,76 +4226,143 @@
 e= %22
-she came to a fork in t
+ She walked through the woods. %22;%0D%0A    four = %22T
 he path
-,
  sh
-ould she go left or right?
+e was on came to a fork%22;%0D%0A    five =%22Left was uphill, right downhill
 %22;%0D%0A    
 four
@@ -4357,23 +4357,21 @@
 %22;%0D%0A    
-four
+six
  =
- 
 %22click o
@@ -4450,16 +4450,27 @@
 ree,four
+, five, six
 );%0D%0A    

increase capacity to 6 lines of text