/************************************************************
 Program:    FizzBuzz
 Author:     Mark Rich   richm@cs.wisc.edu
 Date:       March 8, 2000
 Modified:   March 7, 2001
 Class:      CS 302 - Sections 8 & 10
 ************************************************************/
import javabook2.*;

/**
 * FizzBuzz is a counting game, where you replace certain numbers
 * with words.  Multiples of 3 are replaced with Fizz, multiples
 * of 5 are replaced with Buzz, and multiples of both three and 5
 * are replaced with FizzBuzz.  Play is continued for a user-specified
 * time.
 **/
class FizzBuzz {

    public static void main (String[] args) {
	
	// javabook classes initialization
	MainWindow mw = new MainWindow();
	InputBox in = new InputBox(mw);
	OutputBox out = new OutputBox(mw);
	mw.show();
	out.show();

	// Get the duration of the game from the user.
	int size = in.getInteger("How long do you wish to play FizzBuzz?");
	
	// We loop through and increment by one each time
	for (int i=0; i < size; i++) {

	    // Multiples of 3 and 5 get FizzBuzz
	    if (i % 3 == 0 && i % 5 == 0) {
		out.printLine("FizzBuzz");
	    }

	    // Multiples of only 3 get Fizz
	    else if (i % 3 == 0) {
		out.printLine("Fizz");
	    }

	    // Multiples of only 5 get Buzz
	    else if (i % 5 == 0) {
		out.printLine("Buzz");
	    }

	    // Otherwise say the actual number.
	    else {
		out.printLine(i);
	    }
	}
    }
}
