Roller.java
/* 
 * a Java Main Class - one which can be executed because it has a main method (!: Die does not) 
 */

package chanceapps;

import chance.Die;

public class Roller {
    public static void main(String[] args){
        // CREATE A STANDARD DIE AND ROLL IT 5 TIMES
        createAndRollStandardDieFiveTimes();
        // CREATE A TWENTY SIDED DIE AND ROLL IT 5 TIMES
        createAndRollTwentySidedDieFiveTimes();
        // CREATE A STANDARD DIE AND ROLL IT 20 TIMES
        createAndRollStandardDie(20);
        // CREATE A STANDARD DIE AND ROLL IT 30 TIMES
        createAndRollStandardDie(30);
        // CREATE A TEN SIDED DIE AND ROLL IT 20 TIMES
        createAndRollTenSidedDie(20);
        // CREATE A NINE SIDED DIE AND ROLL IT 30 TIMES
        createAndRollNineSidedDie(30);
        // TEN TIMES, CREATE A STANDARD DIE AND ROLL IT UNTIL YOU GET A 1.
        System.out.println("TEN TIMES, CREATE A STANDARD DIE AND ROLL IT UNTIL YOU GET A 1.");
        for (int i = 1; i <= 10; i++){
            createAndRollStandardDieFor1();
        }
        // TEN TIMES, CREATE A TWELVE DIE AND ROLL IT UNTIL YOU GET A 1.
        System.out.println("TEN TIMES, CREATE A TWELVE SIDED DIE AND ROLL IT UNTIL YOU GET A 1.");
        for(int i = 1 ; i <=10; i++){
            createAndRollTwelveSidedDieFor1();
        }
    }



    private static void createAndRollStandardDieFiveTimes() {
        System.out.println("Roll a standard die 5 times...");
        Die die = new Die();
        die.roll();
        System.out.println(die.top() + "");
        die.roll();
        System.out.println(die.top() + "");
        die.roll();
        System.out.println(die.top() + "");
        die.roll();
        System.out.println(die.top() + "");
        die.roll();
        System.out.println(die.top() + "");
    }

    private static void createAndRollTwentySidedDieFiveTimes() {
        System.out.println("Roll a twenty sided die 5 times...");
        Die twntyDie = new Die(20);
        twntyDie.roll();
        System.out.println(twntyDie.top() + "");
        twntyDie.roll();
        System.out.println(twntyDie.top() + "");
        twntyDie.roll();
        System.out.println(twntyDie.top() + "");
        twntyDie.roll();
        System.out.println(twntyDie.top() + "");
        twntyDie.roll();
        System.out.println(twntyDie.top() + "");
        twntyDie.roll();
        System.out.println(twntyDie.top() + "");
    }

    private static void createAndRollStandardDie(int nrOfTimes) {
        System.out.println("Roll a standard die" + nrOfTimes + "times...");
        Die lucky = new Die();
        for(int i = 1; i <= nrOfTimes; i = i+1){
            lucky.roll();
            System.out.println(lucky.top()+" ");
        }
        System.out.println();
    }

    private static void createAndRollNineSidedDie(int nrOfTimes) {
        System.out.println("Roll a nine-sided die 30 times");
        Die die = new Die(9);
        int i = 1;
        while (i<= nrOfTimes){
            i++;
            die.roll();
            System.out.println(die.top() + "");
        }
        System.out.println();
    }

    private static void createAndRollTenSidedDie(int nrOfTimes) {
        Die decaDie = new Die(10);
        for(int i =1; i<=nrOfTimes; i++){
            decaDie.roll();
            System.out.println(decaDie.top() + " ");
        }
        System.out.println();

    }

    private static void createAndRollTwelveSidedDieFor1() {
        System.out.println("Roll a standard die 5 times...");
        Die twlvDie = new Die (12);
        twlvDie.roll();
        System.out.print(twlvDie.top());
        while (!(twlvDie.top() ==1)){
            twlvDie.roll();
            System.out.print(twlvDie.top());
            break;
        }
        System.out.println();
    }

    private static void createAndRollStandardDieFor1() {
        Die dice = new Die();
        dice.roll();
        System.out.println(dice.top());
        while(!(dice.top() == 1)){
            dice.roll();
            System.out.println(dice.top());
            break;
        }
    }


}