import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

/*
    this is the Controller component
	teacher-provided: creates the environment for the model and the view.
	no student code here.
*/

class Hailstone extends JFrame
{

    private HailstoneView view;
    private HailstoneModel model;
	public static final int MAXSTEPS=500;
	public static int maxSteps;

    Hailstone()
    {
        super("Hailstone");

        // build the view
        view = new HailstoneView();
        view.setBackground(Color.white);
        Container c = getContentPane();
        c.add(view, BorderLayout.CENTER);

        // build the model
        model = new HailstoneModel(view);  
		
		/*
		// example input: get input with GUI input dialog
		String s = JOptionPane.showInputDialog("Enter starting altitude");  
		int start = Integer.parseInt(s)
		*/
		
		// example input: get input with console prompt
        EasyReader console = new EasyReader();
        System.out.print("Enter starting altitude: ");
        int start = console.readInt();
		
		model.solve( start );
    }

    public static void main(String[] args)
    {
        Hailstone denty = new Hailstone();
        denty.addWindowListener(new WindowAdapter()
                                 {
                                     public void windowClosing(WindowEvent e)
                                     {
                                         System.exit(0);
                                     }
                                 }
                                );
        denty.setSize(640, 640);
        denty.show();
    }
}
