Question: public interface IPizza { public void addTopping ( String topping ) ; public void selectCrust ( String crust ) ; public void selectSauce ( String
public interface IPizza
public void addToppingString topping;
public void selectCrustString crust;
public void selectSauceString sauce;
public void orderonlineboolean B;
public void orderwalkinboolean B;
public void payonlinedouble C;
public void paywalkindouble C;
public class UncleMario
public static void mainString args
CustomPizza cP new CustomPizzaDr Js Custom Pizza.";
cPaddToppinganchovies;
cPaddToppingCanadian ham";
cPaddToppingpepperoni;
cPaddToppingonions;
cPaddToppinggreen olives";
cPselectCrustthick;
cPselectSaucemarinara;
cPorderonlinetrue;
System.out.printlncPtoString;
import java.util.ArrayList;
public class CustomPizza implements IPizza
private String name;
private ArrayList toppings new ArrayList;
private String crust;
private String sauce;
private double payonline;
private double paywalkin;
private boolean onlinefalse;
private boolean walkinfalse;
public CustomPizzaString name
namename;
@Override
public String toString
String strPizza;
strPizza"Pizza name: name
;
strPizza"Crust: crust
;
strPizza"Sauce: sauce
;
strPizza"Toppings:
;
forString s:toppings
strPizzats
;
strPizza"Online Order? online
;
strPizza"Walkin Order? walkin
;
return strPizza;
public void addToppingString topping
toppings.addtopping;
public void selectCrustString crust
crustcrust;
public void selectSauceString sauce
saucesauce;
public void orderonlineboolean bOnline
onlinebOnline;
public void orderwalkinboolean bWalkin
walkinbWalkin;
public void payonlinedouble cost
public void paywalkindouble cost
Scenario: Uncle Marios Pizza is expanding his menu. Currently they sell pizzas online or walkin both are take away They want to expand their menu offering to add calzones. Uncle Marios neighbor tried to add a Calzone to the web software and broke all his ordering system by changing the interfaces and concrete classes. Try the link, for ORDER ONLINE; see it is broken. Uncle Mario is hiring you to fix this problem. You are given the main program UncleMario.java, IPizza.java interface, and CustomPizza.java concrete classes. These violate the OOP coding standards of Interface Segregation Principle if we want to add a menu item other than pizza. Firstly, compile the three given files to see how it works and how overriding toString gives you the pizza specifics. Use the given interface IPizzajava and segregate into a new interface for common operations that both pizza and calzone share like the order and pay. Suggested name: IMenuItems.java You still need the interface to support the toppingscrust and sauce operations for pizza. Suggested to reuse the IPizza.java interface only keeping toppings, crust, and sauce. You now have IPizza extend IMenuItems with no change to the CustomPizza class or UncleMario main program class because it implements the IPizza interface. Once you have verified the new IMenuItems interface works the same as earlier for pizza, begin with creating a new interface class. Suggested name: ICalzone.java a Calzone does not allow a crust selection. default is regular b Calzone does not allow a sauce selection. default is marinara c Calzone allows stuffings to be added. Put a new method in the ICalzone.java interface to add stuffings similar to the addToppings from the IPizza interface. Your new ICalzone interface will need to extend the IMenuItems interface. You need a new concrete class for calzone. Suggested name: CustomCalzone.java CustomCalzone.java will need to implement the ICalzone interface and its methods as well as the IMenuItems interface. Much the same as CustomPizza.java class. In the CustomCalzone.java, you will need to override toString to print the calzone specifics of stuffing items and name. No need to print crust or sauce as only Marinara and regular crust are available for calzone. Add code to the UncleMario.java main program to instantiate a new CustomCalzome object. Suggested name cC Add name in the default constructor for CustomCalzone. Add stuffing items. Print the calzone. e Minimum: three interface files, two concrete class files and one main program class file.
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
