Final Project in Programming (Chill and Brew
Final Project in Programming (Chill and Brew
Midterm Project
IT 121 Computer Programming II
Developers:
Godilo, Camela
Berania, Joelheen
Fuentes, Paul Cris
Program Objectives:
1. Allows the person assigned in the casher area to have an easy access to the total amount of
orders
- when the customer picks to types of orders the person assigned in the cashier area will have am easily
access to the total amount of the orders.
2. Automatically shows not only the total amount but at the same time the tax.
- in the selection not only, the total amount is provided but at the same time the tax amount.
3. Provides an honest solution of the total amount that the customer needed to pay
- This tool will help the shop to have an honest calculation of the total amount that the customer needed
to pay, at the same time it will help to have an easy access to any orders and less time consuming.
Class Diagram
The “JFrame” class represents the main window of the app. It has-a “JPanel” class that contains
various components such as a “JComboBox”, “TextField”, and “JButton”. The ”JPanel” class has-a
“JTextField” class for the subtotal, tax and total inputs and a “JButton” class for the convert
button enter Button Exit Button and Clear Button.
The “ActionListener” class is responsible for handling the events when the user clicks on the
total button. This Chill and Brew can provides an honest solution of the total amount that the
customer needed to pay. It automatically shows not only the total amount but at the same time
the tax.
Overall, this class diagram shows the relationships between the classes and how they work
together to convert user’s tax and display the results in the user interface.
UI Design
Source Code
public class NewJFrame extends javax.swing.JFrame {
public NewJFrame() {
initComponents();
@SuppressWarnings("unchecked")
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
redcaramel.addActionListener(new java.awt.event.ActionListener() {
redcaramelActionPerformed(evt);
});
avocado.setText("Avocado 50");
avocado.addActionListener(new java.awt.event.ActionListener() {
avocadoActionPerformed(evt);
});
darkchoco.setFont(new java.awt.Font("Lucida Calligraphy", 1, 12)); // NOI18N
darkchoco.addActionListener(new java.awt.event.ActionListener() {
darkchocoActionPerformed(evt);
});
siomai.setText("Siomai 30");
shawarma.setText("Shawarma 45");
shawarma.addActionListener(new java.awt.event.ActionListener() {
shawarmaActionPerformed(evt);
});
jScrollPane1.setViewportView(txtsub);
txttax.setBackground(new java.awt.Color(102, 255, 204));
jScrollPane2.setViewportView(txttax);
jScrollPane3.setViewportView(txtTot);
jLabel2.setText("Subtotal");
jLabel3.setText("Tax");
jLabel4.setText("Total");
btnenter.setText("Enter");
btnenter.addActionListener(new java.awt.event.ActionListener() {
btnenterActionPerformed(evt);
});
btnclear.setText("Clear");
btnclear.addActionListener(new java.awt.event.ActionListener() {
btnclearActionPerformed(evt);
});
btnexit.setText("Exit");
btnexit.addActionListener(new java.awt.event.ActionListener() {
btnexitActionPerformed(evt);
});
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(redcaramel, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(darkchoco, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(avocado))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(frenchfries, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(shawarma, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnclear)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(btnenter, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnexit, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 101,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(redcaramel)
.addComponent(frenchfries))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(avocado)
.addComponent(siomai))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(darkchoco)
.addComponent(shawarma))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnenter, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(btnclear)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(btnexit)))
.addContainerGap(45, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void redcaramelActionPerformed(java.awt.event.ActionEvent evt) {
if (redcaramel.isSelected())
avocado.setSelected(false);
darkchoco.setSelected(false);
// select Cap
if (avocado.isSelected())
redcaramel.setSelected(false);
darkchoco.setSelected(false);
if (darkchoco.isSelected())
avocado.setSelected(false);
redcaramel.setSelected(false);
double Subtotal = 0;
double Tax;
if (redcaramel.isSelected()){
}else if (avocado.isSelected()){
}else if (darkchoco.isSelected()){
if (frenchfries.isSelected()){
}if (siomai.isSelected()){
}if (shawarma.isSelected()){
txtsub.setText(Double.toString(Subtotal));
Subtotal = Double.parseDouble(txtsub.getText());
txttax.setText(Double.toString(Tax));
txtTot.setText(Double.toString(Total));
// exit JFrame
System.exit(0);
redcaramel.setSelected(false);
darkchoco.setSelected(false);
avocado.setSelected(false);
frenchfries.setSelected(false);
shawarma.setSelected(false);
siomai.setSelected(false);
txtTot.setText("");
txtsub.setText("");
txttax.setText("");
}
/**
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
*/
try {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(() -> {
new NewJFrame().setVisible(true);
});