/** MonthTester.java tests a person's knowledge of the month names.
 * @author Joel Adams, for Alice+Java.
 */

import java.util.*;    // Scanner, Random

public class MonthTester {
	public static void main(String[] args) {
//		testMonth();
		System.out.println("Welcome to the month name game!");
		System.out.println("\nI will give you a month number;");
		System.out.println(" you should enter its name.");
		Scanner kbd = new Scanner(System.in);
		Random rng = new Random();
		char answer;
		do {
			int monthNumber = rng.nextInt(12) + 1;
			System.out.print("\nWhat is the name of month # " 
					          + monthNumber + "? ");
			String response = kbd.next();
			Month m = new Month(monthNumber);
			if ( m.getName().equals(response) ) {
				System.out.println("Correct! Very good!");
			} else {
				System.out.println("Sorry. Month # " 
						+ monthNumber + " is " + m);
			}
			System.out.print("\nDo you want to do another (y or n)? ");
			answer = kbd.next().charAt(0);
		} while ( answer == 'y' || answer == 'Y' );
	}
	
	public static void testMonth() {
		System.out.println("Testing Month...");
		
		// test 1
		Month m1a = new Month(1);
		Month m1b = new Month("January");
		assert m1a.getNumber() == 1;
		assert m1b.getNumber() == 1;
		assert m1a.getName().equals("January");
		assert m1b.getName().equals("January");
		System.out.print(" 1 ");
		
		// test 2
		Month m2a = new Month(2);
		Month m2b = new Month("February");
		assert m2a.getNumber() == 2;
		assert m2b.getNumber() == 2;
		assert m2a.getName().equals("February");
		assert m2b.getName().equals("February");
		System.out.print(" 2 ");

		// test 3
		Month m3a = new Month(3);
		Month m3b = new Month("March");
		assert m3a.getNumber() == 3;
		assert m3b.getNumber() == 3;
		assert m3a.getName().equals("March");
		assert m3b.getName().equals("March");
		System.out.print(" 3 ");
		
		// test 4
		Month m4a = new Month(4);
		Month m4b = new Month("April");
		assert m4a.getNumber() == 4;
		assert m4b.getNumber() == 4;
		assert m4a.getName().equals("April");
		assert m4b.getName().equals("April");
		System.out.print(" 4 ");
		
		// ...
		
		// test 12
		Month m12a = new Month(12);
		Month m12b = new Month("December");
		assert m12a.getNumber() == 12;
		assert m12b.getNumber() == 12;
		assert m12a.getName().equals("December");
		assert m12b.getName().equals("December");
		System.out.print(" 12 ");
		System.out.println("\nAll tests passed!");
}

}
