Question: public interface IPizza { public void addTopping ( String topping ) ; public void selectCrust ( String crust ) ; public void selectSauce ( String

public interface IPizza
{
public void addTopping(String topping);
public void selectCrust(String crust);
public void selectSauce(String sauce);
public void orderonline(boolean B);
public void orderwalkin(boolean B);
public void payonline(double C);
public void paywalkin(double C);
}
public class UncleMario
{
public static void main(String[] args){
CustomPizza cP1= new CustomPizza("Dr. J's Custom Pizza.");
cP1.addTopping("anchovies");
cP1.addTopping("Canadian ham");
cP1.addTopping("pepperoni");
cP1.addTopping("onions");
cP1.addTopping("green olives");
cP1.selectCrust("thick");
cP1.selectSauce("marinara");
cP1.orderonline(true);
System.out.println(cP1.toString());
}
}
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 _online=false;
private boolean _walkin=false;
public CustomPizza(String name){
_name=name;
}
@Override
public String toString(){
String strPizza="";
strPizza+="Pizza name: "+_name+"
";
strPizza+="Crust: "+_crust+"
";
strPizza+="Sauce: "+_sauce+"
";
strPizza+="Toppings:
";
for(String s:_toppings){
strPizza+="\t"+s+"
";
}
strPizza+="Online Order? ="+_online+"
";
strPizza+="Walkin Order? ="+_walkin+"
";
return strPizza;
}
public void addTopping(String topping){
_toppings.add(topping);
}
public void selectCrust(String crust){
_crust=crust;
}
public void selectSauce(String sauce){
_sauce=sauce;
}
public void orderonline(boolean bOnline){
_online=bOnline;
}
public void orderwalkin(boolean bWalkin){
_walkin=bWalkin;
}
public void payonline(double cost){}
public void paywalkin(double cost){}
}
Scenario: Uncle Marios Pizza is expanding his menu. Currently they sell pizzas online or walk-in (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. 1. Firstly, compile the three given files to see how it works and how overriding toString() gives you the pizza specifics. 2. Use the given interface (IPizza.java) and segregate into a new interface for common operations that both pizza and calzone share like the order and pay. (Suggested name: IMenuItems.java)3. You still need the interface to support the toppings,crust, and sauce operations for pizza. Suggested to reuse the IPizza.java interface only keeping toppings, crust, and sauce. 4. You now have IPizza extend IMenuItems with no change to the CustomPizza class or UncleMario main program class because it implements the IPizza interface. 5. 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. 6. Put a new method in the ICalzone.java interface to add stuffings similar to the addToppings() from the IPizza interface. 7. Your new ICalzone interface will need to extend the IMenuItems interface. 8. You need a new concrete class for calzone. (Suggested name: CustomCalzone.java)9. 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.)10. 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.)11. Add code to the UncleMario.java main program to instantiate a new CustomCalzome object. (Suggested name cC1).12. Add name in the default constructor for CustomCalzone. 13. Add stuffing items. 14. 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 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!