/*
 * Created on Nov 4, 2003
 * CS 108 
 * Section A
 */
package hotj.gui1;

import javax.swing.JOptionPane;

/**
 * @author Eric Knibbe
 *
 * This is the GUI for the Pie Slice class. It recieves an angle and radius for a given 
 * pie slice and returns its area. 
 */
public class PieSliceGUI {

	/**
	* The CLI driver itself.  A radius and angle are read in, and the
	* area is displayed.
	*/
	public static void main(String args[]) {
		PieSlice pieSlice = readPieSlice();
		printArea(pieSlice);
		System.exit(0);
	}

	/**
	* The read method. This displays two boxes asking for a radus and angle, and 
	* returns the answers as a new PieSlice object. 
	*/
	private static PieSlice readPieSlice() {
		String radiusString =
			JOptionPane.showInputDialog(
				null,
				"What is the radius of the pie (inches): ",
				"Pie Slice Query Dialog",
				JOptionPane.PLAIN_MESSAGE);
		double radius = Double.parseDouble(radiusString);
		String angleString =
			JOptionPane.showInputDialog(
				null,
				"What is the angle of the pie slice (degrees): ",
				"Pie Slice Query Dialog",
				JOptionPane.PLAIN_MESSAGE);
		double angle = Double.parseDouble(angleString);
		return new PieSlice(radius, angle);

	}

	/**
	* This method creates a box which displays the area for the recieved PieSlice object. 
	*/
	private static void printArea(PieSlice pieSlice) {
		JOptionPane.showMessageDialog(
			null,
			"The area of the slice in square inches is " + pieSlice.area(),
			"Pie Slice Answer Dialog",
			JOptionPane.PLAIN_MESSAGE);
	}
}

