0% found this document useful (0 votes)
5 views2 pages

All Java Code Lab4

The document contains Java code for a pizza ordering system featuring a CustomPizza class that allows users to customize their pizza with toppings, crust, and sauce. The main method demonstrates creating a pizza, adding toppings, selecting crust and sauce, and ordering online. It also includes an IPizza interface that defines methods for pizza customization and ordering options.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

All Java Code Lab4

The document contains Java code for a pizza ordering system featuring a CustomPizza class that allows users to customize their pizza with toppings, crust, and sauce. The main method demonstrates creating a pizza, adding toppings, selecting crust and sauce, and ordering online. It also includes an IPizza interface that defines methods for pizza customization and ordering options.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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<String> _toppings = new ArrayList<String>();
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+"\n";
strPizza+="Crust: "+_crust+"\n";
strPizza+="Sauce: "+_sauce+"\n";
strPizza+="Toppings:\n";
for(String s:_toppings){
strPizza+="\t"+s+"\n";
}
strPizza+="Online Order? = "+_online+"\n";
strPizza+="Walkin Order? = "+_walkin+"\n";
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){}
}
//=================================================================

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);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy