Here is my current code. I need help with getting the set list to work in the pizza and the test code.
package pizza;
import java.util.EnumSet;
import java.util.Set;
import pizza.Pizza.Crust;
import pizza.Pizza.Size;
import pizza.Pizza.Topping;
public class Pizza {
// Declare enums
public enum Size{
SMALL,
MEDIUM,
LARGE,
JUMBO
}
public enum Crust{
CHEESY,
HAND_TOSSEDS,
THIN_AND_CRISPY,
DEEP_PAN
}
public enum Topping{
MUSHROOMS,
GREEN_PEPPERS,
HAM,
PEPPERONI,
SAUGSAGE
}
// declare variables
private Size pizzaSize;
private Crust crustType;
private Set<Topping> setOfToppings = EnumSet.noneOf(Topping.class);
public Pizza(){
}
public void addTopping(Topping topping) {
setOfToppings.add(topping);
}
public Set<Topping> getToppings() {
return setOfToppings;
}
public Pizza(Size pizzaSize, Crust
crustType, Topping greenPeppers, Topping saugsage, Topping
pepperoni) {
this.pizzaSize = pizzaSize;
this.crustType = crustType;
}
public Pizza(Size large, Crust cheesy, Topping greenPeppers) {
// TODO Auto-generated constructor stub
}
public Size getPizzaSize() {
return pizzaSize;
}
public void setPizzaSize(Size pizzaSize) {
this.pizzaSize = pizzaSize;
}
public Crust getCrustType() {
return crustType;
}
public void setCrustType(Crust crustType) {
this.crustType = crustType;
}
public String toString(){
return "A "+pizzaSize+" Pizza with "+ crustType +" crust" + "with " +
setOfToppings + "Toppings";
}
}
Here is my TestCode
package pizza;
import pizza.Pizza.Crust;
import pizza.Pizza.Size;
import pizza.Pizza.Topping;
public class PizzaTest {
public static void main(String[] args) {
// use constructor 1
Pizza vegieCrunch = new Pizza();
vegieCrunch.setCrustType(Crust.THIN_AND_CRISPY);
vegieCrunch.setPizzaSize(Size.MEDIUM);
vegieCrunch.addTopping(Topping.MUSHROOMS);
// constructor 2
Pizza doubleCheese = new Pizza(Size.LARGE, Crust.CHEESY, Topping.GREEN_PEPPERS);
Pizza PartyPizza = new Pizza(Size.JUMBO, Crust.DEEP_PAN, Topping.HAM,
Topping.SAUGSAGE, Topping.PEPPERONI);
// use of getters
System.out.println("Pizza Vegie Crunch::");
System.out.println("Size: "+vegieCrunch.getPizzaSize());
System.out.println("Crust Type: "+vegieCrunch.getCrustType());
System.out.println("Toppings Chosen: " + vegieCrunch.getToppings());
// use of toString
System.out.println("\nPizza Double Cheese:");
System.out.println(doubleCheese.toString());
System.out.println("\nPizza Party Pizza:");
System.out.println(PartyPizza.toString());
}
}
So far it compiles and runs fine however I dont have the add or remove toppings option for the user. I really need help with this, Thank you to everyone!