Question: Could someone help me with this Java assignment? What you need to do: (1) Create the following classes: Enumerated types for WrapType, ProteinType, CheeseType, and

Could someone help me with this Java assignment?

What you need to do: (1) Create the following classes: Enumerated types for WrapType, ProteinType, CheeseType, and DressingType as follows (these should be in separate class files) public enum CheeseType { Swiss, Provolone, Cheddar } public enum DressingType { Sweet, Tangy, Spicy } public enum ProteinType { Tofu, Turkey, Salami } public enum WrapType { Wheat, Roll, Lettuce } Sandwich, a concrete class with the following attributes o wrap (of type WrapEnum) o protein (of type ProteinEnum) o cheese (of type CheeseEnum) o dressing (of type DressingEnum) o oil (boolean) o vinegar (boolean) o a toString() method that prints out what type of wrap, protein, cheese, dressing, salt, pepper, oil, vinegar is on the sandwich

SandwichDecorator, an interface with a single method: public void decorate(Sandwich s); SandwichFactory, a singleton which has two methods o getInstance() a static method that returns access to the SandwichFactory singleton o makeSandwich(String name) a factory method that accepts a string (name of the sandwich) and returns a sandwich of a particular style Acceptable names are Italian o Salami, Roll, Tangy, Provolone Veggie o Tofu, Lettuce, Spicy, Cheddar Tuscan o Turkey, Wheat, Sweet, Swiss

(2) Create two decorator classes that implement the SandwichDecorator interface and modify sandwiches accordingly SaltAndPepperDecorator o decorate() sets salt & pepper to TRUE for Sandwich objects ItalianDecoratorDecorator o decorate() sets oil & vinegar to TRUE for Sandwich objects

(3) Create a class called SandwichShop, which should contain the following code: public class SandwichShop { public static void main(String[] args) { SandwichFactory f = SandwichFactory.getInstance(); Sandwich s1 = f.makeSandwich("Italian"); Sandwich s2 = f.makeSandwich("Veggie"); Sandwich s3 = f.makeSandwich("Tuscan"); SandwichDecorator spd = new SaltPepperDecorator(); SandwichDecorator id = new ItalianDecorator(); id.decorate(s1); id.decorate(s3); spd.decorate(s2); spd.decorate(s1); System.out.println(s1); System.out.println(s2); System.out.println(s3);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!