Commit 3f6f010c authored by harry's avatar harry

First and main submission of assessment program with GUI.

parents
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>netbeanstest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
20x 02 Book
20x 07 Chocolate
Cost before discount: 40
Discount value: 50%
Cost after discount: 20
You paid: 20
Change received: 0
\ No newline at end of file
/*
* 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 harry
*/
public class JComboBox {
}
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JComboBox" name="jComboBox1">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="text" type="java.lang.String" value="jButton2"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" value="Please Select an Item"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="ComboItems" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="check" min="-2" pref="71" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="pickqty" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Component id="price" min="-2" pref="55" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="check2" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel13" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="add2bask" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="bask" alignment="0" min="-2" pref="73" max="-2" attributes="0"/>
<Component id="jLabel9" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="Itemqty" alignment="0" min="-2" pref="73" max="-2" attributes="0"/>
<Component id="jLabel10" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="prodprice" alignment="0" min="-2" pref="64" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel12" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="discountvalue" min="-2" pref="69" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel14" min="-2" pref="332" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="75" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="totalscreen2" min="-2" pref="74" max="-2" attributes="0"/>
<Component id="totalscreen" min="-2" pref="74" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jScrollPane1" min="-2" pref="286" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="53" max="-2" attributes="0"/>
<Component id="jScrollPane2" min="-2" pref="158" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel5" alignment="1" min="-2" pref="45" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jButton3" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="payentry" pref="140" max="32767" attributes="0"/>
<Component id="jButton4" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="65" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel15" min="-2" pref="706" max="-2" attributes="0"/>
<Component id="jLabel16" alignment="0" min="-2" pref="672" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="payresult2" min="-2" pref="618" max="-2" attributes="0"/>
<Component id="payresult" min="-2" pref="618" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="302" max="-2" attributes="0"/>
<Component id="jLabel11" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="590" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="163" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="150" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="180" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="check" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="check2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="add2bask" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="bask" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="pickqty" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="ComboItems" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="Itemqty" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="price" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="prodprice" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane2" alignment="0" min="-2" pref="277" max="-2" attributes="0"/>
<Component id="jScrollPane1" alignment="0" min="-2" pref="277" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="totalscreen" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="totalscreen2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="discountvalue" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel14" min="-2" pref="33" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="payentry" alignment="3" min="-2" pref="48" max="-2" attributes="0"/>
<Group type="102" alignment="3" attributes="0">
<Component id="jLabel15" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="payresult" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="payresult2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="96" max="-2" attributes="0"/>
<Component id="jLabel16" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButton3" min="-2" pref="43" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
<Component id="jButton4" min="-2" pref="42" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="47" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel3">
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
</Component>
<Component class="javax.swing.JComboBox" name="ComboItems">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="9">
<StringItem index="0" value="01 Pen"/>
<StringItem index="1" value="02 Book"/>
<StringItem index="2" value="03 Water"/>
<StringItem index="3" value="04 Drink"/>
<StringItem index="4" value="05 Snack"/>
<StringItem index="5" value="06 Sweet"/>
<StringItem index="6" value="07 Chocolate"/>
<StringItem index="7" value="08 Biscuits"/>
<StringItem index="8" value="09 Cake"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ComboItemsActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="add2bask">
<Properties>
<Property name="text" type="java.lang.String" value="Add to basket"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="add2baskActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="bask">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="baskActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="pickqty">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="20">
<StringItem index="0" value="1"/>
<StringItem index="1" value="2"/>
<StringItem index="2" value="3"/>
<StringItem index="3" value="4"/>
<StringItem index="4" value="5"/>
<StringItem index="5" value="6"/>
<StringItem index="6" value="7"/>
<StringItem index="7" value="8"/>
<StringItem index="8" value="9"/>
<StringItem index="9" value="10"/>
<StringItem index="10" value="11"/>
<StringItem index="11" value="12"/>
<StringItem index="12" value="13"/>
<StringItem index="13" value="14"/>
<StringItem index="14" value="15"/>
<StringItem index="15" value="16"/>
<StringItem index="16" value="17"/>
<StringItem index="17" value="18"/>
<StringItem index="18" value="19"/>
<StringItem index="19" value="20"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pickqtyActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="text" type="java.lang.String" value="Item"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" value="Qty"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="Itemqty">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ItemqtyActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="text" type="java.lang.String" value="Item"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="text" type="java.lang.String" value="Qty"/>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="basketview">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JTextField" name="price">
<Properties>
<Property name="editable" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="priceActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="check">
<Properties>
<Property name="editable" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="checkActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="prodprice">
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Price"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="check2">
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="priceview">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="ITEMS"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="text" type="java.lang.String" value="PRICE"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="totalscreen">
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="text" type="java.lang.String" value="TOTAL"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="text" type="java.lang.String" value="Item Price"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="DISCOUNT"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="totalscreen2">
</Component>
<Component class="javax.swing.JTextField" name="discountvalue">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="discountvalueActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel14">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Lucida Grande" size="24" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="PAYMENT "/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="payentry">
<Properties>
<Property name="text" type="java.lang.String" value="Give payment here"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="payentryActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton3">
<Properties>
<Property name="text" type="java.lang.String" value="PAY"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel15">
</Component>
<Component class="javax.swing.JLabel" name="jLabel16">
</Component>
<Component class="javax.swing.JLabel" name="payresult">
<Properties>
<Property name="text" type="java.lang.String" value="Welcome to SCS Shopping"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="payresult2">
<Properties>
<Property name="text" type="java.lang.String" value="Welcome to SCS Shopping"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton4">
<Properties>
<Property name="text" type="java.lang.String" value="PRINT RECIEPT"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton4ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
import static java.io.File.separator;
import java.util.ArrayList;
import java.util.Arrays;
import javax.swing.JOptionPane;
import java.util.Random;
import java.io.FileWriter;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open template in the editor.
*/
/**
*
* @author harry
*/
public class NewJFrame extends javax.swing.JFrame {
/**
* Creates new form NewJFrame
*/
//array for the set menu, which will be defined and added to later on in the program.
public NewJFrame() {
initComponents();
}
ArrayList<Integer> pricelist = new ArrayList<Integer>();
ArrayList<String> shoplist = new ArrayList<String>();
int penstock = 20;
int bookstock = 20;
int waterstock = 20;
int drinkstock = 20;
int snackstock = 20;
int sweetstock = 20;
int chocstock = 20;
int biscstock = 20;
int cakestock = 20;
String message1 = "Thankyou. Press below to print your reciept. Please take your items.";
String error1 = "You have not provided enough for today's transaction. It will be cancelled";
String message2 = "Thankyou. Press below to print your reciept, your change will be processed now. Please take your items.";
String default1 = "Welcome to SCS Shopping.";
String strfinalcost;
String strpaygiven;
int finalcost;
int paygiven;
/**
* 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() {
jComboBox1 = new javax.swing.JComboBox<>();
jButton2 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
ComboItems = new javax.swing.JComboBox<>();
add2bask = new javax.swing.JButton();
bask = new javax.swing.JTextField();
pickqty = new javax.swing.JComboBox<>();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
Itemqty = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
basketview = new javax.swing.JTextArea();
price = new javax.swing.JTextField();
check = new javax.swing.JTextField();
prodprice = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
check2 = new javax.swing.JTextField();
jScrollPane2 = new javax.swing.JScrollPane();
priceview = new javax.swing.JTextArea();
jLabel2 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
totalscreen = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
totalscreen2 = new javax.swing.JTextField();
discountvalue = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
payentry = new javax.swing.JTextField();
jButton3 = new javax.swing.JButton();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
payresult = new javax.swing.JLabel();
payresult2 = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jButton2.setText("jButton2");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Please Select an Item");
ComboItems.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "01 Pen", "02 Book", "03 Water", "04 Drink", "05 Snack", "06 Sweet", "07 Chocolate", "08 Biscuits", "09 Cake" }));
ComboItems.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ComboItemsActionPerformed(evt);
}
});
add2bask.setText("Add to basket");
add2bask.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
add2baskActionPerformed(evt);
}
});
bask.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
baskActionPerformed(evt);
}
});
pickqty.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" }));
pickqty.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pickqtyActionPerformed(evt);
}
});
jLabel7.setText("Item");
jLabel8.setText("Qty");
Itemqty.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ItemqtyActionPerformed(evt);
}
});
jLabel9.setText("Item");
jLabel10.setText("Qty");
basketview.setColumns(20);
basketview.setRows(5);
jScrollPane1.setViewportView(basketview);
price.setEditable(false);
price.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
priceActionPerformed(evt);
}
});
check.setEditable(false);
check.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
checkActionPerformed(evt);
}
});
jLabel1.setText("Price");
priceview.setColumns(20);
priceview.setRows(5);
jScrollPane2.setViewportView(priceview);
jLabel2.setText("ITEMS");
jLabel11.setText("PRICE");
jLabel12.setText("TOTAL");
jLabel13.setText("Item Price");
jButton1.setText("DISCOUNT");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
discountvalue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
discountvalueActionPerformed(evt);
}
});
jLabel14.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
jLabel14.setText("PAYMENT ");
payentry.setText("Give payment here");
payentry.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
payentryActionPerformed(evt);
}
});
jButton3.setText("PAY");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
payresult.setText("Welcome to SCS Shopping");
payresult2.setText("Welcome to SCS Shopping");
jButton4.setText("PRINT RECIEPT");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(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()
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ComboItems, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(check, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(pickqty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(price, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(check2)
.addGap(18, 18, 18)
.addComponent(jLabel13)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(add2bask)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(bask, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Itemqty, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(prodprice, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel12)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(discountvalue, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 332, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(75, 75, 75)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(totalscreen2, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(totalscreen, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(53, 53, 53)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jLabel4)
.addComponent(jLabel3)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton3)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(payentry, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(65, 65, 65)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 706, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 672, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(payresult2, javax.swing.GroupLayout.PREFERRED_SIZE, 618, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(payresult, javax.swing.GroupLayout.PREFERRED_SIZE, 618, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(302, 302, 302)
.addComponent(jLabel11)))
.addGap(0, 590, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGap(163, 163, 163)
.addComponent(jLabel3)
.addGap(26, 26, 26)
.addComponent(jLabel4)
.addGap(150, 150, 150)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel6)
.addGap(180, 180, 180))
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(jLabel10)
.addComponent(check, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(check2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(add2bask)
.addComponent(bask, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pickqty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ComboItems, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Itemqty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(price, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(prodprice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel11))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(totalscreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(totalscreen2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(discountvalue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(payentry, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel15)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(payresult)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(payresult2)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(96, 96, 96)
.addComponent(jLabel16))
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(23, 23, 23)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(47, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void baskActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_baskActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_baskActionPerformed
private void add2baskActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add2baskActionPerformed
// TODO add your handling code here:
String item;
String Qty;
String Cost;
int itemtotal;
String pickcost;
String total;
String tempitem;
bask.setText((String)ComboItems.getSelectedItem());
Itemqty.setText((String)pickqty.getSelectedItem());
Qty = Itemqty.getText();
int quantity = Integer.parseInt(Qty);
item = bask.getText();
Cost = price.getText();
int cost = Integer.parseInt(Cost);
itemtotal = cost * quantity;
tempitem = Qty + "x " + item;
shoplist.add(tempitem);
basketview.append(tempitem + "\n");
String ItemTotal = String.valueOf(itemtotal);
prodprice.setText(ItemTotal);
pickcost = prodprice.getText();
int pickedcost = Integer.parseInt(pickcost) ;
pricelist.add(pickedcost);
int sum = 0;
for(int i = 0; i < pricelist.size(); i++){
sum = sum + pricelist.get(i);
}
priceview.append(pickedcost + "\n");
total = String.valueOf(sum);
totalscreen.setText(total);
System.out.println("Total: " + total);
System.out.println("Selected items array: " + pricelist);
String startprice = totalscreen.getText();
totalscreen2.setText(startprice);
switch (item){
case "01 Pen":
penstock = penstock - quantity;
break;
case "02 Book":
bookstock = bookstock - quantity;
break;
case "03 Water":
waterstock = waterstock - quantity;
break;
case "04 Drink":
drinkstock = drinkstock - quantity;
break;
case "05 Snack":
snackstock = snackstock - quantity;
break;
case "06 Sweet":
sweetstock = sweetstock - quantity;
break;
case "07 Chocolate":
chocstock = chocstock - quantity;
break;
case "08 Biscuits":
biscstock = biscstock - quantity;
break;
case "09 Cake":
cakestock = cakestock - quantity;
break;
}
System.out.println("Pen stock: " + penstock);
System.out.println("Book stock: " + bookstock);
System.out.println("Water stock: " + waterstock);
System.out.println("Drink stock: " + drinkstock);
System.out.println("Snack stock: " + snackstock);
System.out.println("Sweet stock: " + sweetstock);
System.out.println("Chocolate stock: " + chocstock);
System.out.println("Biscuits stock: " + biscstock);
System.out.println("Cake stock: " + cakestock);
}//GEN-LAST:event_add2baskActionPerformed
private void ComboItemsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComboItemsActionPerformed
String item;
check.setText((String)ComboItems.getSelectedItem());
item = check.getText();
switch (item){
case "01 Pen" :
price.setText("1");
break;
case "02 Book" :
price.setText("1");
break;
case "03 Water" :
price.setText("1");
break;
case "04 Drink" :
price.setText("1");
break;
case "05 Snack" :
price.setText("2");
break;
case "06 Sweet" :
price.setText("1");
break;
case "07 Chocolate" :
price.setText("1");
break;
case "08 Biscuits" :
price.setText("1");
break;
case "09 Cake" :
price.setText("2");
break;
}
// TODO add your handling code here:
}//GEN-LAST:event_ComboItemsActionPerformed
private void pickqtyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pickqtyActionPerformed
// TODO add your handling code here:
check2.setText((String)pickqty.getSelectedItem());
}//GEN-LAST:event_pickqtyActionPerformed
private void ItemqtyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ItemqtyActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_ItemqtyActionPerformed
private void priceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_priceActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_priceActionPerformed
private void checkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_checkActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
Random random = new Random();
int rand = 0;
while(true){
rand = random.nextInt(11);
if(rand !=0) break;
}
System.out.println(rand);
double discount;
int newprice;
String total = totalscreen.getText();
double bigtotal = Integer.parseInt(total);
String finaltotal;
int calc1;
String dcnum;
switch (rand){
case 1 :
discount = 0.1;
dcnum = "10%";
discountvalue.setText(dcnum);
calc1 = (int) (bigtotal * discount);
newprice = (int) (bigtotal - calc1);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
case 2 :
discount = 0.2;
dcnum = "20%";
discountvalue.setText(dcnum);
calc1 = (int) (bigtotal * discount);
newprice = (int) (bigtotal - calc1);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
case 3 :
discount = 0.3;
dcnum = "30%";
discountvalue.setText(dcnum);
calc1 = (int) (bigtotal * discount);
newprice = (int) (bigtotal - calc1);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
case 4 :
discount = 0.4;
dcnum = "40%";
discountvalue.setText(dcnum);
calc1 = (int) (bigtotal * discount);
newprice = (int) (bigtotal - calc1);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
case 5 :
discount = 0.5;
dcnum = "50%";
discountvalue.setText(dcnum);
calc1 = (int) (bigtotal * discount);
newprice = (int) (bigtotal - calc1);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
case 6 :
discount = 5;
dcnum = "SAVE £5";
discountvalue.setText(dcnum);
newprice = (int) (bigtotal - discount);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
case 7 :
discount = 5;
dcnum = "SAVE £5";
discountvalue.setText(dcnum);
newprice = (int) (bigtotal - discount);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
case 8 :
discount = 5;
dcnum = "SAVE £5";
discountvalue.setText(dcnum);
newprice = (int) (bigtotal - discount);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
case 9 :
discount = 5;
dcnum = "SAVE £5";
discountvalue.setText(dcnum);
newprice = (int) (bigtotal - discount);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
case 10 :
discount = 5;
dcnum = "SAVE £5";
discountvalue.setText(dcnum);
newprice = (int) (bigtotal - discount);
finaltotal = Integer.toString(newprice);
totalscreen2.setText(finaltotal);
break;
}
}//GEN-LAST:event_jButton1ActionPerformed
private void discountvalueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_discountvalueActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_discountvalueActionPerformed
private void payentryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_payentryActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_payentryActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
strfinalcost = totalscreen2.getText();
strpaygiven = payentry.getText();
finalcost = Integer.parseInt(strfinalcost);
paygiven = Integer.parseInt(strpaygiven);
if (finalcost == paygiven){
payresult.setText(message1);
payresult2.setText(default1);
}
else if(finalcost > paygiven){
payresult.setText(error1);
payresult2.setText(default1);
}
else if(finalcost < paygiven){
payresult.setText(message2);
int change = paygiven - finalcost;
Integer.toString(change);
payresult2.setText("£" + (Integer.toString(change)) + " change.");
}
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
String Items = basketview.getText();
String Cost = totalscreen.getText();
String discount = discountvalue.getText();
String discCost = totalscreen2.getText();
String Payment = payentry.getText();
String Change = Integer.toString(paygiven - finalcost);
try{
FileWriter receipt = new FileWriter("receipt.txt");
receipt.write(Items);
receipt.write("\n" + "Cost before discount: " + Cost);
receipt.write("\n" + "Discount value: " + discount);
receipt.write("\n" + "Cost after discount: " + discCost);
receipt.write("\n" + "You paid: " + Payment);
receipt.write("\n" + "Change received: " + Change);
receipt.write("\n" + "Thankyou for shopping at SCS Shopping");
receipt.close();
}catch(Exception e){System.out.println(e);}
}//GEN-LAST:event_jButton4ActionPerformed
/**
* @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(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.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 NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox<String> ComboItems;
private javax.swing.JTextField Itemqty;
private javax.swing.JButton add2bask;
private javax.swing.JTextField bask;
private javax.swing.JTextArea basketview;
private javax.swing.JTextField check;
private javax.swing.JTextField check2;
private javax.swing.JTextField discountvalue;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JComboBox<String> jComboBox1;
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 jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
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.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextField payentry;
private javax.swing.JLabel payresult;
private javax.swing.JLabel payresult2;
private javax.swing.JComboBox<String> pickqty;
private javax.swing.JTextField price;
private javax.swing.JTextArea priceview;
private javax.swing.JTextField prodprice;
private javax.swing.JTextField totalscreen;
private javax.swing.JTextField totalscreen2;
// 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