/*
 *2013-09-08
 *HW: Unit 2 Practice Assignment: Ch4 Exercise 5c
 *Bradley Forney
 *CIS 127
 *Professor: Craig Sharp
 * 
 */
 
public class Sandwich
{
	//Initialize internal variables
	private int bread=0;
	private int filling=0;
	private int calories=0;
	StringBuilder name = new StringBuilder(""); //StringBuilder allows for 
	//dynamic String concatenation needed here (for adding fillings to bread 
	//type to create Sandwich name)
	
	//Constructor
	Sandwich(int breadType,int fillingType)
	{
		bread=breadType;
		filling=fillingType;
		
		//Options for bread decision. Assigns name and calories to respective variables
		switch (bread)
		{
			case 1:
				Bread wheat = new Bread("Wheat", 230);
				calories=calories+(2*wheat.getBreadCalories());
				name.append("Wheat");
				break;
									
			case 2:
				Bread white = new Bread("White", 150);
				calories=calories+(2*white.getBreadCalories());
				name.append("White");
				break;
				
			case 3:
				Bread rye 	= new Bread("Rye", 320);
				calories=calories+(2*rye.getBreadCalories());
				name.append("Rye");
				break;
							
			default:
				System.out.println("Invalid sandwich entry!");
		}
		
		//Options for filling decision. Appends name and calories to respective variables
		//"name.append" adds filling name to end of name variable.
		switch (filling)
		{
			case 1:
				SandwichFilling cheese	= new SandwichFilling("Cheese", 600);
				calories=calories+cheese.getFillingCalories();
				name.append(" & Cheese");
				break;
									
			case 2:
				SandwichFilling eggsalad = new SandwichFilling("Egg Salad", 650);
				calories=calories+eggsalad.getFillingCalories();
				name.append(" & Egg Salad");
				break;
				
			case 3:
				SandwichFilling salami = new SandwichFilling("Salami", 500);
				calories=calories+salami.getFillingCalories();
				name.append(" & Salami");
				break;
							
			default:
				System.out.println("Invalid sandwich entry!");
		}
	}
	
	
	//***GETS***
	//Returns calories for entire sandwich
	public int getSandwichCalories()
	{
		return calories;
	}
	
	//Returns full name of sandwich
	public String getSandwichName()
	{		
		return name.toString(); //returns full name value. Is coverted from 
		//StringBuilder to String type before returning.
	}	
}
