/**
 * @file TreeStory.java
 * @author Valery Samovich
 * @version 1
 * @date 2015/05/11
 */

package com.samovich.basics.concepts.strings.treehouse;

import java.io.Console;
import java.util.Scanner;

public class TreeStory {

    public static void main(String[] args) {
        // __Name__ is a __adjective__ __noun__.
        // They are always __adverb__ __verb__.

        // Console console = System.console();
        // String name = console.readLine("Enter a name:  ");
        // String adjective = console.readLine("Enter an adjective:  ");
        // String noun = console.readLine("Enter a noun:  ");
        // String adverb = console.readLine("Enter an adverb:  ");
        // String verb = console.readLine("Enter a verb ending with -ing:  ");
        // console.printf("Your TreeStory:\n----------------\n");
        // console.printf("%s is a $s %s. ", name, adjective, noun);
        // console.printf("They are always %s %s.\n", adverb, verb);

        // Create the scanner object
        Scanner scanner = new Scanner(System.in);
        System.out.println("How old are you? ");
        // Convert and store age as integer
        String ageScanner = scanner.nextLine();

        int age = Integer.parseInt(ageScanner);
        // Age validation.
        if (age < 13) {
            // Exit code
            System.out.println("You must be at least 13 to use this program.\n");
            System.exit(0);
        }

        System.out.println("Enter a name:  ");
        // Accept user input for name
        String name = scanner.nextLine();
        System.out.println("Enter an adjective:  ");
        String adjective = scanner.nextLine();

        System.out.println("Enter a noun: ");
        String noun = scanner.nextLine();
        // Noun validation.
        if(noun.equalsIgnoreCase("dork")) {
            System.out.println("This language is not allowed. Exiting. \n\n");
            System.exit(0);
        }

        System.out.println("Enter an adverb: ");
        String adverb = scanner.nextLine();
        System.out.println("Enter a verb ending with -ing:  ");
        String verb = scanner.nextLine();
        // Print the prototype
        System.out.println("Your TreeStory:\n--------------\n");
        System.out.println(name + " is a " + adjective + " " + noun + ".");
        System.out.println("He is always " + adverb + " " + verb + ".");
    }
}

@@ -1311,12 +1311,20 @@
 xit 
-code
+the rpogram.
 %0A   
@@ -1661,32 +1661,101 @@
 er.nextLine();%0A%0A
+        String noun;%0A        boolean isInvalidWord;%0A        do %7B%0A    
         System.o
@@ -1788,30 +1788,27 @@
 %22);%0A        
-String
+   
  noun = scan
@@ -1835,39 +1835,99 @@
     
-// Noun validation.%0A        if(
+    isInvalidWord = (noun.equalsIgnoreCase(%22dork%22) %7C%7C%0A                                     
 noun
@@ -1949,18 +1949,86 @@
 se(%22
-do
+je
 rk%22))
- %7B%0A
+;%0A            // Noun validation.%0A            if (isInvalidWord) %7B%0A    
     
@@ -2089,15 +2089,17 @@
 ed. 
-Exit
+Try aga
 in
-g
 . %5Cn
@@ -2120,33 +2120,41 @@
     
-System.exit(0);%0A        %7D
+%7D%0A        %7D while(isInvalidWord);
 %0A%0A  

Add do while loop