Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions