OOP PROJECT REPORT2. Project Title:
Domino’s Pizza
Domino’s Pizza:
Domino's Pizza is the recognized world leader in pizza delivery. Founded in 1960, Domino's is the
second-largest pizza chain in the United States (after Pizza Hut) and the largest worldwide, with more
than 10,000 corporate and franchised stores in 70 countries.
3. SUMMARY OF A PROJECT:
This program will allow users to order a pizza with just a couple of clicks. The order will be a step by step
by procedure. The user will be able to select from a range of Pizzas on the menu or make a Pizza of their
own by choosing from different types of crusts, toppings, sidelines. When the order ends, the program
will display the total cost depending on the toppings, crusts etc.
4. Code:
package javaapplication40;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.ButtonGroup;
import javax.swing.JRadioButton;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import java.awt.Color;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.awt.event.ActionEvent;
5. import java.awt.event.ActionListener;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.BoxLayout;
import javax.swing.JOptionPane;
public class JavaApplication40 {
public static void main(String[] args)throws IOException {
Order obj=new Order();
}
}
class Order extends JFrame implements ActionListener
{
int total=0,sizecost=0,crustcost=0,flavorcost=0,veggiescost=0,drinkscost=0,sidescost=0;
int toppings=0,drinks=0,sides=0;
int count=0;
boolean flag=false;
String crust,flavor,size,sauce,veggies;
String text;
JPanel sizePanel=new JPanel();
6. JPanel crustPanel=new JPanel();
JPanel fvPanel=new JPanel();
JButton submitButton=new JButton();
JButton resetButton=new JButton();
JButton addButton=new JButton();
JTextArea totalTextArea=new JTextArea();
JMenu pepsimenu=new JMenu("Pepsi");
JMenu fantamenu=new JMenu("Fanta");
JMenu spritemenu=new JMenu("Sprite");
JMenuItem p_one=new JMenuItem("1");
JMenuItem p_two=new JMenuItem("2");
JMenuItem p_three=new JMenuItem("3");
JMenuItem p_four=new JMenuItem("4");
JMenuItem f_one=new JMenuItem("1");
JMenuItem f_two=new JMenuItem("2");
JMenuItem f_three=new JMenuItem("3");
JMenuItem f_four=new JMenuItem("4");
JMenuItem s_one=new JMenuItem("1");
JMenuItem s_two=new JMenuItem("2");
JMenuItem s_three=new JMenuItem("3");
JMenuItem s_four=new JMenuItem("4");
Order() throws IOException
{
7. super();
//The Main Frame
setTitle("Dominos Pakistan");
setSize(1024,786);
setLocation(0,0);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
getContentPane().setBackground(Color.WHITE);
FlowLayout f1=new FlowLayout();
//The Dominos Header Panel
JPanel headerPanel= new JPanel();
headerPanel.setSize(1280,200);
headerPanel.setBackground(Color.BLUE);
headerPanel.setLayout(f1);
BufferedImage headerPicture = ImageIO.read(new
File("C:UsersMinahilDocumentsProjectheader.jpg"));
JLabel headerLabel = new JLabel(new ImageIcon(headerPicture));
headerPanel.add(headerLabel);
//The Panel in which user chooses the type of Crust
crustPanel.setBackground(Color.ORANGE);
crustPanel.setLayout(new BoxLayout(crustPanel,BoxLayout.Y_AXIS));
//The 'Crust' Image used inside a Label
8. JLabel crustLabel=new JLabel();
ImageIcon crustImage=new ImageIcon("C:UsersMinahilDocumentsProjectcrust.jpg");
crustLabel.setIcon(crustImage);
crustPanel.add(crustLabel);
//The Radio Buttons used under the Crust Option
JRadioButton normalRadioButton=new JRadioButton("Normal");
normalRadioButton.addActionListener(this);
normalRadioButton.setBackground(Color.ORANGE);
JRadioButton thinzaRadioButton=new JRadioButton("Thinza");
thinzaRadioButton.addActionListener(this);
thinzaRadioButton.setBackground(Color.ORANGE);
ButtonGroup crustButtonGroup=new ButtonGroup();
crustButtonGroup.add(normalRadioButton);
crustButtonGroup.add(thinzaRadioButton);
crustPanel.add(normalRadioButton);
crustPanel.add(thinzaRadioButton);
JLabel completeLabel=new JLabel();
ImageIcon completeImage=new
ImageIcon("C:UsersMinahilDocumentsProjectcomplete.jpg");
completeLabel.setIcon(completeImage);
crustPanel.add(completeLabel);
JLabel contactLabel=new JLabel();
9. ImageIcon contactImage=new ImageIcon("C:UsersMinahilDocumentsProjectcontact.jpg");
contactLabel.setIcon(contactImage);
crustPanel.add(contactLabel);
JTextField contactTextField=new JTextField();
contactTextField.setMaximumSize(new
Dimension(Integer.MAX_VALUE,contactTextField.getPreferredSize().height));
crustPanel.add(contactTextField);
JLabel nameLabel=new JLabel();
ImageIcon nameImage=new ImageIcon("C:UsersMinahilDocumentsProjectname.jpg");
nameLabel.setIcon(nameImage);
crustPanel.add(nameLabel);
JTextField nameTextField=new JTextField();
nameTextField.setMaximumSize(new
Dimension(Integer.MAX_VALUE,nameTextField.getPreferredSize().height));
crustPanel.add(nameTextField);
JLabel addressLabel=new JLabel();
ImageIcon addressImage=new ImageIcon("C:UsersMinahilDocumentsProjectaddress.jpg");
addressLabel.setIcon(addressImage);
crustPanel.add(addressLabel);
JTextField addressTextField=new JTextField();
crustPanel.add(addressTextField);
10. //The Panel in which user selects size of the Pizza
sizePanel.setBackground(Color.ORANGE);
sizePanel.setPreferredSize(new Dimension(400,100));
sizePanel.setLayout(f1);
sizePanel.setLayout(new BoxLayout(sizePanel,BoxLayout.Y_AXIS));
//The 'Size' Image used inside a Label
JLabel sizeLabel=new JLabel();
ImageIcon sizeImage=new ImageIcon("C:UsersMinahilDocumentsProjectsize.jpg");
sizeLabel.setIcon(sizeImage);
sizePanel.add(sizeLabel);
//The buttons under the Size option
JRadioButton sliceRadioButton=new JRadioButton("Slice");
sliceRadioButton.addActionListener(this);
sliceRadioButton.setBackground(Color.ORANGE);
JRadioButton halfRadioButton=new JRadioButton("Half");
halfRadioButton.addActionListener(this);
halfRadioButton.setBackground(Color.ORANGE);
JRadioButton fullRadioButton=new JRadioButton("Full");
fullRadioButton.addActionListener(this);
fullRadioButton.setBackground(Color.ORANGE);
ButtonGroup sizeButtonGroup=new ButtonGroup();
14. JPanel saucePanel=new JPanel();
saucePanel.setBackground(Color.green);
saucePanel.setLayout(f1);
//The 'Sauce' Image used inside a label
JLabel sauceLabel=new JLabel();
ImageIcon sauceImage=new ImageIcon("C:UsersMinahilDocumentsProjectsauce.jpg");
sauceLabel.setIcon(sauceImage);
saucePanel.add(sauceLabel);
//The options after the Sauce label
JRadioButton mildRadioButton=new JRadioButton("Mild");
mildRadioButton.addActionListener(this);
mildRadioButton.setBackground(Color.green);
JRadioButton hotRadioButton=new JRadioButton("Hot");
hotRadioButton.addActionListener(this);
hotRadioButton.setBackground(Color.green);
JRadioButton extrahotRadioButton=new JRadioButton("Extra Hot");
extrahotRadioButton.addActionListener(this);
extrahotRadioButton.setBackground(Color.green);
ButtonGroup sauceButtonGroup=new ButtonGroup();
sauceButtonGroup.add(mildRadioButton);
sauceButtonGroup.add(hotRadioButton);
sauceButtonGroup.add(extrahotRadioButton);
15. saucePanel.add(mildRadioButton);
saucePanel.add(hotRadioButton);
saucePanel.add(extrahotRadioButton);
//The Add Another, Reset and Next Button
addButton.addActionListener(this);
addButton.setBackground(Color.GREEN);
ImageIcon addImage=new ImageIcon("C:UsersMinahilDocumentsProjectadd.jpg");
addButton.setIcon(addImage);
saucePanel.add(addButton);
resetButton.addActionListener(this);
resetButton.setBackground(Color.GREEN);
ImageIcon resetImage=new ImageIcon("C:UsersMinahilDocumentsProjectreset.jpg");
resetButton.setIcon(resetImage);
saucePanel.add(resetButton);
submitButton.addActionListener(this);
submitButton.setBackground(Color.GREEN);
ImageIcon submitImage=new ImageIcon("C:UsersMinahilDocumentsProjectsubmit.jpg");
submitButton.setIcon(submitImage);
saucePanel.add(submitButton);
//The panel in which options for flavor and vegetables is selected
fvPanel.setBackground(Color.ORANGE);
16. fvPanel.setPreferredSize(new Dimension(400,100));
fvPanel.setLayout(new BoxLayout(fvPanel,BoxLayout.Y_AXIS));
//The 'Flavor' image used inside a label
JLabel flavorLabel=new JLabel();
ImageIcon flavorImage=new ImageIcon("C:UsersMinahilDocumentsProjectflavor.jpg");
flavorLabel.setIcon(flavorImage);
fvPanel.add(flavorLabel);
//The options displayed after Flavor
JRadioButton cheeseRadioButton=new JRadioButton("Cheese");
cheeseRadioButton.addActionListener(this);
cheeseRadioButton.setBackground(Color.ORANGE);
JRadioButton fajitaRadioButton=new JRadioButton("Chicken Fajita");
fajitaRadioButton.addActionListener(this);
fajitaRadioButton.setBackground(Color.ORANGE);
JRadioButton tikkaRadioButton=new JRadioButton("Chicken Tikka");
tikkaRadioButton.addActionListener(this);
tikkaRadioButton.setBackground(Color.ORANGE);
JRadioButton pepperoniRadioButton=new JRadioButton("Pepperoni");
pepperoniRadioButton.addActionListener(this);
pepperoniRadioButton.setBackground(Color.ORANGE);
JRadioButton vegiRadioButton=new JRadioButton("Vegitarian");
vegiRadioButton.addActionListener(this);
vegiRadioButton.setBackground(Color.ORANGE);
19. }
@Override
public void actionPerformed(ActionEvent ex)
{
//switch-case statements for the selection of size of pizza
switch (ex.getActionCommand())
{
case "Slice":
{
size="Slice of a Pizza";
sizecost=250;
break;
}
case "Half":
{
size="Half a Pizza";
sizecost=800;
break;
}
case "Full":
{
size="Full Pizza";
sizecost=1500;
break;
}
20. }
//switch-case statements for the selection of crust of pizza
switch (ex.getActionCommand())
{
case "Normal":
{
crust="Normal Crust";
crustcost=0;
break;
}
case "Thinza":
{
crust="Thinza Crust";
crustcost=100;
break;
}
}
//switch-case statements for the selection of flavor
switch (ex.getActionCommand())
{
case "Cheese":
{
flavor="Cheese";
flavorcost=100;
break;
21. }
case "Chicken Fajita":
{
flavor="Chicken Fajita";
flavorcost=200;
break;
}
case "Chicken Tikka":
{
flavor="Chicken Tikka";
flavorcost=150;
break;
}
case "Pepperoni":
{
flavor="Pepperoni";
flavorcost=200;
break;
}
case "Vegitarian":
{
flavor="Vegitarian";
28. if(ex.getSource()==submitButton)
{
totalcost();
if(flag==true){
totalTextArea.setText("Your order isn"+text+size+"nWith "+crust+
"nFlavor:"+flavor+"nSauce:"+sauce+"nWith "+toppings+
" Toppings"+"nOrder Also includes "+sides+" Sides"+
"nAnd "+drinks+" Drinks"+"nThe Total is = "+total);
submitButton.setVisible(false);
}
else{
totalTextArea.setText("Your order isn"+size+"nWith "+crust+
"nFlavor:"+flavor+"nSauce:"+sauce+"nWith "+toppings+
" Toppings"+"nOrder Also includes "+sides+" Sides"+
"nAnd "+drinks+" Drinks"+"nThe Total is = "+total);
submitButton.setVisible(false);
}
}
else if(ex.getSource()==addButton){
totalcost();
JOptionPane.showMessageDialog(this,"Press Ok to add another pizza to your order","Add
Another", JOptionPane.PLAIN_MESSAGE);
text = size+"nWith "+crust+
32. CLASS DIAGRAM
ORDER
Order()
public void actionPerformed(ActionEvent ex)
public void totalcost()
int total=0, sizecost=0, crustcost=0, flavorcost=0,
veggiescost=0, drinkscost=0, sidescost=0, toppings=0,
drinks=0, sides=0, count=0;
boolean flag=false;
String crust,flavor,size,sauce,veggies,text;