 /*****************************************************************
 * Program2 : Blob Manager 
 * Programmer: Insert your name here 
 * 
 * Due Date: Insert Due Date
 * Class: COMP 110-01         Instructor: Tyler Johnson
 *         
 * Pledge: I have neither given nor received unauthorized aid
 * on this program.     (signature on file)
 *
 * Description:  This class helps manage a pet Blob by providing 
 *              methods to determine its color, size, and diameter 
 *              as well as a method to feed it.
 *
 * Input: This class requires a Blob as input.
 *
 * Output: This class has no general outputs; it exists to help
 *         modify the a Blob object. Some of the methods have
 *         outputs as described in their javadoc.
 *
 ******************************************************************/


import java.awt.Color;

public class BlobManager {
	
	//A variable holding our pet blob
	private Blob myBlob;
	
	//Constants that hold values for our specific colors
	private final Color GREEN = Color.GREEN;
	private final Color RED = Color.RED;
	private final Color BLUE = Color.CYAN;
	private final Color PURPLE = Color.MAGENTA;

	/**
	 * This method will take in a number as a parameter 
	 * that corresponds to a color that we want to change
	 * the blob to. Color 0 is green, Color 1 is red, Color 2
	 * is blue/cyan, and Color 3 is magenta/purple. If a number
	 * other than 0-3 is specified, the color should default to green.
	 * 
	 * @param colorNumber a number corresponding to the color we want to change the blob to
	 * @return the corresponding color
	 */
	public Color getBlobColor(int colorNumber){
		
		//Declare a variable holding the new color the blob will be
		// and initialize its color to GREEN
		Color newColor=GREEN;
		
		
		/* ************ MAKE CHANGES HERE ************ */
		
		//Convert the incorrect series of if-else statements 
		// below into a correct switch statement using the 
		// values on the lab page.
		if (colorNumber==0)
			newColor=GREEN;
		else if (colorNumber==1)
			newColor=RED;
		else
			newColor=RED;
		
		/* *************** END CHANGES *************** */
		
		
		//Return the new color we have determined above
		return newColor;
	}
	
	/**
	 * This method will repeatedly call the feed() method for the blob
	 * so that we can feed it some pizza. The feed() method will be called
	 * the number of times indicated in numSlices.
	 * 
	 * @param numSlices the number of slices to feed the blob
	 */
	public void feedPizzaToBlob(int numSlices){
		
		/* ************ MAKE CHANGES HERE ************ */
		
		//Here you need to change the code to include a while loop
		// that will feed our blob the number of slices passed via
		// the int numSlices.
		
		//The incorrect code below will feed the blob 5 times, 
		// regardless of the value of numSlices.
		myBlob.feed();
		myBlob.feed();
		myBlob.feed();
		myBlob.feed();
		myBlob.feed();
		
		/* *************** END CHANGES *************** */
		
	}
	
	
	/**
	 * This method will return a String that corresponds to the
	 * size of a blob, based on its diameter. For example, a blob
	 * with diameter 75 would be "Medium".
	 * 
	 * @param blobDiameter the diameter of our blob
	 * @return String containing the size of our blob, e.g. "Large"
	 */
	public String getBlobSizeAsString(int blobDiameter){
		
		//Declare a String called blobSize that will tell us how large
		// our blob is in relative terms.
		String blobSize = "Unknown";
		
		/* ************ MAKE CHANGES HERE ************ */
		
		//The code below only has two sizes. You need to modify
		// the code to do all the sizes shown in the table on
		// the lab page by using additional if-else statements.
		
		if (blobDiameter<20)
			blobSize="Microscopic";
		else
			blobSize="Tiny";
		
		/* *************** END CHANGES *************** */
		
		//Return the String we created so it can be displayed
		return blobSize;
		
	}

	/**
	 * This method will calculate the radius of the blob given its area.
	 * 
	 * @param area the total area of our blob (as a result of pizzas eaten)
	 * @return int containing the corresponding radius of the blob
	 */
	public int calculateBlobDiameter(int area){
		
		//Create a constant PI for use in calculation
		final double PI = Math.PI;
		
		//Create a variable for the diameter, and initialize it
		int diameter=0;
		
		/* ************ MAKE CHANGES HERE ************ */
		
		//Here we need to do the calculation to determine the diameter.
		// The below calculation is incorrect and needs to be fixed.
		// You will need the constant PI we defined above, as well as
		// the Math.sqrt() function.
		
		//This formula is wrong. Put in a new one!
		diameter=area/10;
		
		/* *************** END CHANGES *************** */
		
		//Return the diameter we calculated
		return diameter;
	}
	
	
	/**
	 * Sets the current blob we are working with
	 * (no changes should be made)
	 * 
	 * @param newBlob the new blob we will work with
	 */
	public void setBlob(Blob newBlob){
		//Sets our blob to the newBlob sent in as a parameter
		// (no changes needed)
		myBlob=newBlob;
	}
	
	/**
	 * Main method
	 * (no changes should be made)
	 * 
	 * @param args Arguments from the command line
	 */
	public static void main(String[] args){
		//Create a new BlobManager to interact with our blob
		BlobManager manager = new BlobManager();
		//Create a new blob named roberto that interacts with our blob manager
		Blob roberto = new Blob("Roberto", manager);
	}

}
