import java.util.*;

/**
 * EightBallDriver - This one does no validation 
 *
 * @author Michael Norton & Nancy Harris
 * @version V4 Oct 17, 2008
 */
public class EightBallDriverV4
{
	public static void main( String[] args )
	{
		// declarations
		EightBall ball;
		Scanner scan;
		String question;	 // 8 Ball question
		String cQuestion;  // continuation question
		boolean flag;		 // true if question is good
		
		// instantiations
		ball = new EightBall();
		scan = new Scanner( System.in );

		System.out.print("Do you want to play Eight Ball? ");
		cQuestion = scan.nextLine();
		
		while (cQuestion.equalsIgnoreCase("yes"))
		{
			// do 8 ball stuff
			do
			{
				flag = true;
				System.out.print( "\nAsk a question of the Magic 8 Ball: " );
				question = scan.nextLine(); 		
			
				// validate question - > 0, <= 60, ends with ?
	
				// choose one error message
				if (question.length() == 0)
				{
					System.out.println("An empty message is not allowed.");
					flag = false;
				}
				else if (question.length() > 60)
				{
					System.out.println("Your message is too long.");
					flag = false;
				}
				else if (question.charAt(question.length() - 1) != '?')
				{
					System.out.println("You must use a question.");
					flag = false;
				}
				// else no else in this case. 
				
			}while (!flag); // if true, then exit and answer the question 		
			
			// echo question and print the answer
			System.out.println( "\nYour question: " + question);
			System.out.println( "Your answer:   " + ball.shakeEightBall01() + "\n" );
			
			// ask the question again
			System.out.print("Do you want to play again? ");
			cQuestion = scan.nextLine();
		}	
	} // method main

} // class EightBallDriver