Commit bc78af3f authored by stewart.ndungu's avatar stewart.ndungu

COM4001M_Stewart_Ndungu

parent 85b1144e
import java.util.ArrayList;
import java.io.*;
import java.io.FileOutputStream;
import java.util.Random;
import static javax.management.Query.value;
import static javax.management.Query.value;
import static javax.management.Query.value;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Stephen
*/
public class assessment extends javax.swing.JFrame {
double var1;
String opr="";
static ArrayList<String>itemName = new ArrayList<String>();
static ArrayList<String>itemNume = new ArrayList<String>();
static ArrayList<Integer> itemCode = new ArrayList<Integer>();
static ArrayList<Integer>itemCude = new ArrayList<Integer>();
static ArrayList<Double> itemPrice = new ArrayList<Double>();
static ArrayList<Double> itemPruce4 = new ArrayList<Double>();
static ArrayList<Double> itemPruce1 = new ArrayList<Double>();
static ArrayList<Double> itemPruce2 = new ArrayList<Double>();
static ArrayList<Double> itemPruce3 = new ArrayList<Double>();
static ArrayList<Double> itemPruce5 = new ArrayList<Double>();
static ArrayList<Integer> itemQty = new ArrayList<Integer>();
static ArrayList<Integer> itemQyy = new ArrayList<Integer>();
static ArrayList<String> itemDescription = new ArrayList<String>();
static ArrayList<String> basketName = new ArrayList<String>();
static ArrayList<String> basketNume = new ArrayList<String>();
static ArrayList<Integer> basketCode = new ArrayList<Integer>();
static ArrayList<Integer>basketCude = new ArrayList<Integer>();
static ArrayList<Float> basketPrice = new ArrayList<Float>();
static ArrayList<Float> basketPruce = new ArrayList<Float>();
static ArrayList<Integer> basketQty = new ArrayList<Integer>();
static ArrayList<Integer> basketQyy = new ArrayList<Integer>();
static ArrayList<String> basketDescription = new ArrayList<String>();
/**
* Creates new form assessment
*/
public assessment() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jSelectname = new javax.swing.JComboBox<>();
jLabel1 = new javax.swing.JLabel();
jFinalPrice = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jAdditem = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jSelectname1 = new javax.swing.JComboBox<>();
jSelectname2 = new javax.swing.JComboBox<>();
jSelectname3 = new javax.swing.JComboBox<>();
jSelectname4 = new javax.swing.JComboBox<>();
jSelectname5 = new javax.swing.JComboBox<>();
jSelectname6 = new javax.swing.JComboBox<>();
jSelectname7 = new javax.swing.JComboBox<>();
jSelectname8 = new javax.swing.JComboBox<>();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel12 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jLabel13 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea2 = new javax.swing.JTextArea();
jTextField2 = new javax.swing.JTextField();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jSelectname.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select Product", "Water 2L", "Fanta", "Coke ", "Heineken 440 ML", "Guiness 440 ML", "Chocolate", "Cake", "Biscuits", " " }));
jSelectname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectnameActionPerformed(evt);
}
});
jLabel1.setText("0");
jFinalPrice.setText("SubTotal");
jFinalPrice.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jFinalPriceActionPerformed(evt);
}
});
jLabel2.setText("jLabel2");
jAdditem.setText("Add item");
jAdditem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jAdditemActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jSelectname1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select Product", "Water 2L", "Fanta", "Coke ", "Heineken 440 ML", "Guiness 440 ML", "Chocolate", "Cake", "Biscuits", " " }));
jSelectname1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectname1ActionPerformed(evt);
}
});
jSelectname2.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select Product", "Water 2L", "Fanta", "Coke ", "Heineken 440 ML", "Guiness 440 ML", "Chocolate", "Cake", "Biscuits" }));
jSelectname2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectname2ActionPerformed(evt);
}
});
jSelectname3.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select Product", "Water 2L", "Fanta", "Coke ", "Heineken 440 ML", "Guiness 440 ML", "Chocolate", "Biscuits", "Cake" }));
jSelectname3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectname3ActionPerformed(evt);
}
});
jSelectname4.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select Product", "Water 2L", "Fanta", "Coke ", "Heineken 440 ML", "Guiness 440 ML", " " }));
jSelectname4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectname4ActionPerformed(evt);
}
});
jSelectname5.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select Product", "Water 2L", "Fanta", "Coke ", "Heineken 440 ML", "Guiness 440 ML", " " }));
jSelectname5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectname5ActionPerformed(evt);
}
});
jSelectname6.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select Product", "Water 2L", "Fanta", "Coke ", "Heineken 440 ML", "Guiness 440 ML", " " }));
jSelectname6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectname6ActionPerformed(evt);
}
});
jSelectname7.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select Product", "Water 2L", "Fanta", "Coke ", "Heineken 440 ML", "Guiness 440 ML", " " }));
jSelectname7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectname7ActionPerformed(evt);
}
});
jSelectname8.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select Product", "Water 2L", "Fanta", "Coke ", "Heineken 440 ML", "Guiness 440 ML", " " }));
jSelectname8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectname8ActionPerformed(evt);
}
});
jLabel3.setText("0");
jLabel4.setText("0");
jLabel5.setText("0");
jLabel6.setText("0");
jLabel7.setText("0");
jLabel8.setText("0");
jLabel9.setText("0");
jLabel10.setText("0");
jTextField1.setText("Enter Amount for Payment");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jLabel11.setText("jLabel11");
jButton1.setText("Pay");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel12.setText("jLabel12");
jButton2.setText("Discount");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jLabel13.setText("jLabel13");
jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jScrollPane2.setViewportView(jTextArea2);
jTextField2.setText("Receipt");
jButton3.setText("Receipt");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSelectname1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSelectname2, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSelectname3, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSelectname4, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(jFinalPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(176, 176, 176)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSelectname, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSelectname5, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSelectname6, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSelectname7, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSelectname8, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(204, 204, 204)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 278, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(78, 78, 78))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jAdditem, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(122, 122, 122)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(176, 176, 176)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(71, 71, 71)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 399, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGap(58, 58, 58))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSelectname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSelectname1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSelectname2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSelectname3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSelectname4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jButton3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSelectname5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSelectname6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSelectname7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSelectname8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)))
.addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(46, 46, 46)
.addComponent(jAdditem)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jFinalPrice)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton2)
.addGap(8, 8, 8)
.addComponent(jButton1)
.addGap(39, 39, 39))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(jLabel12))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jSelectnameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectnameActionPerformed
// Select products
if (jSelectname.getSelectedItem().equals("Water 2L")){jLabel1.setText("2.19");
}
if (jSelectname.getSelectedItem().equals("Heineken 440 ML")){jLabel1.setText( "5.99");
}
if (jSelectname.getSelectedItem().equals("Guiness 440 ML")){jLabel1.setText( "5.99");
}
if (jSelectname.getSelectedItem().equals("Fanta")){jLabel1.setText( "2.19");
}
if (jSelectname.getSelectedItem().equals("Coke")){jLabel1.setText( "2.19");
if (jSelectname.getSelectedItem().equals("Chocolate")){jLabel1.setText( "1");
}
if (jSelectname.getSelectedItem().equals("Biscuits")){jLabel1.setText( "1");
}
if (jSelectname.getSelectedItem().equals("Cake")){jLabel1.setText( "2");
}
}
// TODO add your handling code here:
}//GEN-LAST:event_jSelectnameActionPerformed
private void jFinalPriceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFinalPriceActionPerformed
// It will get the Total of the products before discount.
jLabel2.setText(String.valueOf(Double.parseDouble(jLabel1.getText()) + Double.parseDouble(jLabel3.getText()) + Double.parseDouble(jLabel4.getText()) + Double.parseDouble(jLabel5.getText()) + Double.parseDouble(jLabel6.getText()) + Double.parseDouble(jLabel7.getText())+ Double.parseDouble(jLabel8.getText()) + Double.parseDouble(jLabel9.getText())+ Double.parseDouble(jLabel10.getText()) ) );
// TODO add your handling code here:
}//GEN-LAST:event_jFinalPriceActionPerformed
private void jAdditemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAdditemActionPerformed
//Adds items to a list for a receipt later on
jTextArea1.setText( jSelectname.getSelectedItem()+ "\t" + jLabel1.getText() +"\n" + jSelectname1.getSelectedItem()+ "\t" + jLabel3.getText()+ "\n" + jSelectname2.getSelectedItem()+ "\t" + jLabel4.getText() + "\n" + jSelectname3.getSelectedItem()+ "\t" +jLabel5.getText()
+ "\n"+ jSelectname4.getSelectedItem()+ "\t" +jLabel6.getText()+ "\n" +jSelectname5.getSelectedItem()+ "\t" +jLabel7.getText()+ "\n"+ jSelectname6.getSelectedItem()+ "\t" +jLabel8.getText() + "\n" + jSelectname7.getSelectedItem()+ "\t" +jLabel9.getText()+ "\n"+
jSelectname8.getSelectedItem()+ "\t" +jLabel10.getText() );
}//GEN-LAST:event_jAdditemActionPerformed
private void jSelectname1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectname1ActionPerformed
// It will get the Total of the products before discount.
if (jSelectname1.getSelectedItem().equals("Water 2L ")){
jLabel3.setText("Water 2L" + "2.19") ;
}
if (jSelectname1.getSelectedItem().equals("Heineken 440 ML")){jLabel3.setText( "5.99");
}
if (jSelectname1.getSelectedItem().equals("Guiness 400 ML")){jLabel3.setText( "5.99");
}
if (jSelectname1.getSelectedItem().equals("Fanta")){jLabel3.setText( "2.19");
}
if (jSelectname1.getSelectedItem().equals("Coke")){jLabel3.setText( "2.19");
}
if (jSelectname1.getSelectedItem().equals("Chocolate")){jLabel3.setText( "1");
}
if (jSelectname1.getSelectedItem().equals("Biscuits")){jLabel3.setText( "1");
}
if (jSelectname1.getSelectedItem().equals("Cake")){jLabel3.setText( "2");
}
// TODO add your handling code here:
}//GEN-LAST:event_jSelectname1ActionPerformed
private void jSelectname2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectname2ActionPerformed
// It will get the Total of the products before discount.
if (jSelectname2.getSelectedItem().equals("Water 2L")){jLabel4.setText("2.19");
}
if (jSelectname2.getSelectedItem().equals("Heineken 440 ML")){jLabel4.setText( "5.99");
}
if (jSelectname2.getSelectedItem().equals("Guiness 440 ML")){jLabel4.setText( "5.99");
}
if (jSelectname2.getSelectedItem().equals("Fanta")){jLabel4.setText( "2.19");
}
if (jSelectname2.getSelectedItem().equals("Coke")){jLabel4.setText( "2.19");
}
if (jSelectname2.getSelectedItem().equals("Chocolate")){jLabel4.setText( "1");
}
if (jSelectname2.getSelectedItem().equals("Biscuits")){jLabel4.setText( "1");
}
if (jSelectname2.getSelectedItem().equals("Cake")){jLabel4.setText( "2");
}
// TODO add your handling code here:
}//GEN-LAST:event_jSelectname2ActionPerformed
private void jSelectname3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectname3ActionPerformed
// It will get the Total of the products before discount.
if (jSelectname3.getSelectedItem().equals("Water 2L")){jLabel5.setText("2.19");
}
if (jSelectname3.getSelectedItem().equals("Heineken 440 ML")){jLabel5.setText( "5.99");
}
if (jSelectname3.getSelectedItem().equals("Guiness 440 ML")){jLabel5.setText( "5.99");
}
if (jSelectname3.getSelectedItem().equals("Fanta")){jLabel5.setText( "2.19");
}
if (jSelectname3.getSelectedItem().equals("Coke")){jLabel5.setText( "2.19");
if (jSelectname3.getSelectedItem().equals("Chocolate")){jLabel5.setText( "1");
}
if (jSelectname3.getSelectedItem().equals("Biscuits")){jLabel5.setText( "1");
}
if (jSelectname3.getSelectedItem().equals("Cake")){jLabel5.setText( "2");
}
}
// TODO add your handling code here:
}//GEN-LAST:event_jSelectname3ActionPerformed
private void jSelectname4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectname4ActionPerformed
// It will get the Total of the products before discount.
if (jSelectname4.getSelectedItem().equals("Water 2L")){jLabel6.setText("2.19");
}
if (jSelectname4.getSelectedItem().equals("Heineken 440 ML")){jLabel6.setText( "5.99");
}
if (jSelectname4.getSelectedItem().equals("Guiness 440 ML")){jLabel6.setText( "5.99");
}
if (jSelectname4.getSelectedItem().equals("Fanta")){jLabel6.setText( "2.19");
}
if (jSelectname4.getSelectedItem().equals("Coke")){jLabel6.setText( "2.19");
}if (jSelectname4.getSelectedItem().equals("Chocolate")){jLabel6.setText( "1");
}
if (jSelectname4.getSelectedItem().equals("Biscuits")){jLabel6.setText( "1");
}
if (jSelectname4.getSelectedItem().equals("Cake")){jLabel6.setText( "2");
}
// TODO add your handling code here:
}//GEN-LAST:event_jSelectname4ActionPerformed
private void jSelectname5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectname5ActionPerformed
// It will get the Total of the products before discount.
if (jSelectname5.getSelectedItem().equals("Water 2L")){jLabel7.setText("2.19");
}
if (jSelectname5.getSelectedItem().equals("Heineken 440 ML")){jLabel7.setText( "5.99");
}
if (jSelectname5.getSelectedItem().equals("Guiness 440 ML")){jLabel7.setText( "5.99");
}
if (jSelectname5.getSelectedItem().equals("Fanta")){jLabel7.setText( "2.19");
}
if (jSelectname5.getSelectedItem().equals("Coke")){jLabel7.setText( "2.19");
if (jSelectname5.getSelectedItem().equals("Chocolate")){jLabel7.setText( "1");
}
if (jSelectname5.getSelectedItem().equals("Biscuits")){jLabel7.setText( "1");
}
if (jSelectname5.getSelectedItem().equals("Cake")){jLabel7.setText( "2");
}
}
// TODO add your handling code here:
}//GEN-LAST:event_jSelectname5ActionPerformed
private void jSelectname6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectname6ActionPerformed
// It will get the Total of the products before discount.
if (jSelectname6.getSelectedItem().equals("Water 2L")){jLabel8.setText("2.19");
}
if (jSelectname6.getSelectedItem().equals("Heineken 440 ML")){jLabel8.setText( "5.99");
}
if (jSelectname6.getSelectedItem().equals("Guiness 440 ML")){jLabel8.setText( "5.99");
}
if (jSelectname6.getSelectedItem().equals("Fanta")){jLabel8.setText( "2.19");
}
if (jSelectname6.getSelectedItem().equals("Coke")){jLabel8.setText( "2.19");
}if (jSelectname1.getSelectedItem().equals("Chocolate")){jLabel8.setText( "1");
}
if (jSelectname6.getSelectedItem().equals("Biscuits")){jLabel8.setText( "1");
}
if (jSelectname6.getSelectedItem().equals("Cake")){jLabel8.setText( "2");
}
// TODO add your handling code here:
}//GEN-LAST:event_jSelectname6ActionPerformed
private void jSelectname7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectname7ActionPerformed
// It will get the Total of the products before discount.
if (jSelectname7.getSelectedItem().equals("Water 2L")){jLabel9.setText("2.19");
}
if (jSelectname7.getSelectedItem().equals("Heineken 440 ML")){jLabel9.setText( "5.99");
}
if (jSelectname7.getSelectedItem().equals("Guiness 440 ML")){jLabel9.setText( "5.99");
}
if (jSelectname7.getSelectedItem().equals("Fanta")){jLabel9.setText( "2.19");
}
if (jSelectname7.getSelectedItem().equals("Coke")){jLabel9.setText( "2.19");
}if (jSelectname7.getSelectedItem().equals("Chocolate")){jLabel9.setText( "1");
}
if (jSelectname7.getSelectedItem().equals("Biscuits")){jLabel9.setText( "1");
}
if (jSelectname7.getSelectedItem().equals("Cake")){jLabel9.setText( "2");
}
// TODO add your handling code here:
}//GEN-LAST:event_jSelectname7ActionPerformed
private void jSelectname8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectname8ActionPerformed
// It will get the Total of the products before discount.
if (jSelectname8.getSelectedItem().equals("Water 2L")){jLabel10.setText("2.19");
}
if (jSelectname8.getSelectedItem().equals("Heineken 440 ML")){jLabel10.setText( "5.99");
}
if (jSelectname8.getSelectedItem().equals("Guiness 440 ML")){jLabel10.setText( "5.99");
}
if (jSelectname8.getSelectedItem().equals("Fanta")){jLabel10.setText( "2.19");
}
if (jSelectname8.getSelectedItem().equals("Coke")){jLabel10.setText( "2.19");
if (jSelectname8.getSelectedItem().equals("Chocolate")){jLabel10.setText( "1");
}
if (jSelectname8.getSelectedItem().equals("Biscuits")){jLabel10.setText( "1");
}
if (jSelectname8.getSelectedItem().equals("Cake")){jLabel10.setText( "2");
}
}
// TODO add your handling code here:
}//GEN-LAST:event_jSelectname8ActionPerformed
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
//aEnter ammount to pat
// TODO add your handling code here:
}//GEN-LAST:event_jTextField1ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
//By clicking the button, you can pay for the products
jLabel11.setText(String.valueOf(Double.parseDouble(jTextField1.getText()) - Double.parseDouble(jLabel3.getText())));
if (Double.parseDouble(jTextField1.getText()) < Double.parseDouble(jLabel3.getText()) ){
jLabel12.setText("Insufficient Amount ");
}else{
jLabel12.setText("Please take your product!");
}
// TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
//Get a random numbe that will be plugged in to get a discount amount
Random rand= new Random();
double minRange = 1, maxRange=10;
double value=rand.nextInt((int) (maxRange - minRange))+minRange;
double Value2,Value3,Value2A;
Value2= ((value/10) * Double.parseDouble(jLabel2.getText()));
Value2A= (Double.parseDouble(jLabel2.getText()) - Value2);
jLabel13.setText(String.valueOf(Value2A));
jButton2.setText(String.valueOf(value));
// TODO add your handling code here:
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// collect all the a items/payments/amount/discount into one area
jTextArea2.setText(jTextArea1.getText() + "\n" + jLabel13.getText()+"\n"+ "Amountpaid" + jTextField1.getText()+"\n" + "Change" + jLabel11.getText()); // TODO add your handling code here:
}//GEN-LAST:event_jButton3ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<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.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(assessment.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(assessment.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(assessment.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(assessment.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new assessment().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jAdditem;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jFinalPrice;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JComboBox<String> jSelectname;
private javax.swing.JComboBox<String> jSelectname1;
private javax.swing.JComboBox<String> jSelectname2;
private javax.swing.JComboBox<String> jSelectname3;
private javax.swing.JComboBox<String> jSelectname4;
private javax.swing.JComboBox<String> jSelectname5;
private javax.swing.JComboBox<String> jSelectname6;
private javax.swing.JComboBox<String> jSelectname7;
private javax.swing.JComboBox<String> jSelectname8;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextArea jTextArea2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration//GEN-END:variables
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment