Question: There is a key design patterns that are used in the code above. State the pattern and describe which classes play which roles in the
There is a key design patterns that are used in the code above. State the pattern and describe which classes play which roles in the pattern. Also Draw a class diagram depicting the classes and their relationships.
Beef.java
public class Beef implements Protein
public String add
return "Protein added is Beef";
BeefDish.java
public class BeefDish extends Food
public BeefDishProtein protein
superprotein;
@Override
public String cook
return "BeefDish cooked. protein.add;
Chicken.java
public class Chicken implements Protein
public String add
return "Protein added is Chicken";
ChickenDish.java
public class ChickenDish extends Food
public ChickenDishProtein protein
superprotein;
@Override
public String cook
return "ChickenDish cooked. protein.add;
Food.java
public abstract class Food
protected Protein protein;
standard constructors
abstract public String cook;
public FoodProtein protein
this.protein protein;
Protein.java
public interface Protein
String add;
Test.java
public class Test
public static void mainString args
a dish with beef
Food dish new BeefDishnew Beef;
System.out.printlndishcook;
a dish with protein
Food dish new ChickenDishnew Chicken;
System.out.printlndishcook;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
