//below I have initialised the available stock of 20 for each menu item. This gets updated upon a successful transaction within the system.
intpenstock=20;
intbookstock=20;
intwaterstock=20;
...
...
@@ -57,11 +58,13 @@ public class NewJFrame extends javax.swing.JFrame {
intbiscstock=20;
intcakestock=20;
//below are 3 messages used at the end of the program which I have stored here for both ease and in case they need to be used multiple times in different areas.
Stringmessage1="Thankyou. Press below to print your reciept. Please take your items.";
Stringerror1="You have not provided enough for today's transaction. It will be cancelled";
Stringmessage2="Thankyou. Press below to print your reciept, your change will be processed now. Please take your items.";
Stringdefault1="Welcome to SCS Shopping.";
//here are a few variables used in different methods that I have places here for ease when building the payment section.
Stringstrfinalcost;
Stringstrpaygiven;
intfinalcost;
...
...
@@ -419,11 +422,11 @@ public class NewJFrame extends javax.swing.JFrame {
System.out.println("Selected items array: "+pricelist);// backup line shown in standard output to show up to date cost, assisted when building the program
Stringstartprice=totalscreen.getText();
Stringstartprice=totalscreen.getText();// fetching total value to be added to discount price text area until updated manually
totalscreen2.setText(startprice);
totalscreen2.setText(startprice);//adding total to 2nd text area
switch(item){
...
...
@@ -526,9 +531,9 @@ public class NewJFrame extends javax.swing.JFrame {
break;
}
}//switch case used to recognise item selected and update quantities
//tools used to assist development and check to see stock changes
System.out.println("Pen stock: "+penstock);
System.out.println("Book stock: "+bookstock);
System.out.println("Water stock: "+waterstock);
...
...
@@ -564,12 +569,12 @@ public class NewJFrame extends javax.swing.JFrame {
check.setText((String)ComboItems.getSelectedItem());//filling a text area to show recognition of item selected in dropdown box
item=check.getText();
item=check.getText();// getting a string variable from box filled above for use in switch case
switch(item){
...
...
@@ -611,7 +616,7 @@ public class NewJFrame extends javax.swing.JFrame {
}
//switch case used to update the price listing for an item once it has been selected in the dropdown box, shows corresponding price for item curently selected
...
...
@@ -634,7 +639,7 @@ public class NewJFrame extends javax.swing.JFrame {