Commit cc3fcfcd authored by karl.templeton's avatar karl.templeton

Delete SelfService

parent b14ebc55
import java.awt.Color;
import java.lang.reflect.Array;
import java.util.Random;
import javax.swing.DefaultListModel;
import java.util.Scanner;
import java.util.ArrayList;
/**
*
* @author karlt
*/
public class ShoppingSystem1 extends javax.swing.JFrame {
/**
* Creates new form ShoppingSystem1
*/
public ShoppingSystem1() {
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">
private void initComponents() {
jFrame1 = new javax.swing.JFrame();
list1 = new java.awt.List();
jLabel1 = new javax.swing.JLabel();
jButton11 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jButton12 = new javax.swing.JButton();
jLabel11 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox<>();
jButton1 = new javax.swing.JButton();
jTextField3 = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jLabel2 = new javax.swing.JLabel();
jComboBox2 = new javax.swing.JComboBox<>();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
getContentPane().add(list1);
list1.setBounds(550, 90, 153, 302);
jLabel1.setFont(new java.awt.Font("Verdana Pro Light", 1, 18)); // NOI18N
jLabel1.setText("ShoppingSystem");
getContentPane().add(jLabel1);
jLabel1.setBounds(305, 6, 160, 65);
jButton11.setText("Discount");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
getContentPane().add(jButton11);
jButton11.setBounds(540, 510, 90, 22);
jTextField1.setEditable(false);
getContentPane().add(jTextField1);
jTextField1.setBounds(540, 540, 90, 22);
jTextField2.setEditable(false);
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
getContentPane().add(jTextField2);
jTextField2.setBounds(650, 540, 110, 22);
jButton12.setText("Total");
getContentPane().add(jButton12);
jButton12.setBounds(650, 510, 110, 22);
getContentPane().add(jLabel11);
jLabel11.setBounds(600, 400, 0, 0);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Please Select An Item", "Pen", "Book", "Water", "Drink", "Snack", "Sweet", "Chocolate", "Biscuit", "Cake", "" }));
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
getContentPane().add(jComboBox1);
jComboBox1.setBounds(190, 100, 170, 22);
jButton1.setText("Remove All");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(190, 190, 170, 22);
jTextField3.setEditable(false);
getContentPane().add(jTextField3);
jTextField3.setBounds(190, 80, 170, 22);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{"Code", "01", "02", "03", "04", "05", "06", "07", "08", "9"},
{"Price", "£1.00", "£1.00", "£1.00", "£1.00", "£2.00", "£1.00", "£1.00", "£1.00", "£2.00"},
{"Quantity", "20", "20", "20", "20", "20", "20", "20", "20", "20"},
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null}
},
new String [] {
"Title 1", "Pen", "Book", "Water", "Drink", "Snack", "Sweet", "Chocolate", "Biscuit", "Cake"
}
) {
boolean[] canEdit = new boolean [] {
true, false, false, false, false, false, false, false, false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(jTable1);
getContentPane().add(jScrollPane1);
jScrollPane1.setBounds(0, 470, 530, 130);
getContentPane().add(jLabel2);
jLabel2.setBounds(550, 400, 150, 0);
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Remove Certain Items", "Pen", "Book", "Water", "Drink", "Snack", "Sweet", "Chocolate", "Biscuit", "Cake", "" }));
jComboBox2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox2ActionPerformed(evt);
}
});
getContentPane().add(jComboBox2);
jComboBox2.setBounds(189, 150, 170, 22);
pack();
}// </editor-fold>
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
Random random = new Random();
int randInt1 = random.nextInt(10);
if(randInt1 == 1)
{
jTextField1.setText("10%");
}
if(randInt1 == 2)
{
jTextField1.setText("20%");
}
if(randInt1 == 3)
{
jTextField1.setText("30%");
}
if(randInt1 == 4)
{
jTextField1.setText("40%");
}
if(randInt1 == 5)
{
jTextField1.setText("50%");
}
if(randInt1 > 5)
{
jTextField1.setText("£5 off");
}
jButton11.setEnabled(false);
}
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
if (jComboBox1.getSelectedItem().toString().equals("Pen")){
//Display Item Description
jTextField3.setText("A Good and Sturdy Pen");
//Adding the Price to The Total
//Item Ticker
//Displaying items in the list1
list1.add("Pen");
}
if (jComboBox1.getSelectedItem().toString().equals("Book")){
//Display Item Description
jTextField3.setText("Your Favourite Book");
//Adding the Price to the Total
//Item Ticker
//Displaying items in the list1
list1.add("Book");
}
if (jComboBox1.getSelectedItem().toString().equals("Water")){
//Display Item Description
jTextField3.setText("A Bottle Of Water");
//Adding the Price to the Total
//Item Ticker
//Displaying items in the list1
list1.add("Water");
}
if (jComboBox1.getSelectedItem().toString().equals("Drink")){
//Display Item Description
jTextField3.setText("A Drink");
//Adding the Price to the Total
//Item Ticker
//Displaying items in the list1
list1.add("Drink");
}
if (jComboBox1.getSelectedItem().toString().equals("Snack")){
//Display Item Description
jTextField3.setText("Your Favourite Snack");
//Adding the Price to the Total
//Item Ticker
//Displaying items in the list1
list1.add("Snack");
}
if (jComboBox1.getSelectedItem().toString().equals("Sweet")){
//Display Item Description
jTextField3.setText("Your Favourite Sweets");
//Adding the Price to the Total
//Item Ticker
//Displaying items in the list1
list1.add("Sweet");
}
if (jComboBox1.getSelectedItem().toString().equals("Chocolate")){
//Display Item Description
jTextField3.setText("A Bar Of Chocolate");
//Adding the Price to the Total
//Item Ticker
//Displaying items in the list1
list1.add("Chocolate");
}
if (jComboBox1.getSelectedItem().toString().equals("Biscuit")){
//Display Item Description
jTextField3.setText("A Packet Of Biscuits");
//Items in Basket
//Item Ticker
//Displaying items in the list1
list1.add("Biscuit");
}
if (jComboBox1.getSelectedItem().toString().equals("Cake")){
//Display Item Description
jTextField3.setText("A Slice Of Cake");
//Items in Basket
//Item Ticker
//Displaying items in the list1
list1.add("Cake");
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
list1.removeAll();
}
private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {
if (jComboBox1.getSelectedItem().toString().equals("Pen")){
list1.remove("Pen");
}
if (jComboBox1.getSelectedItem().toString().equals("Water")){
list1.remove("Water");
}
if (jComboBox1.getSelectedItem().toString().equals("Book")){
list1.remove("Book");
}
if (jComboBox1.getSelectedItem().toString().equals("Drink")){
list1.remove("Drink");
}
if (jComboBox1.getSelectedItem().toString().equals("Snack")){
list1.remove("Snack");
}
if (jComboBox1.getSelectedItem().toString().equals("Sweet")){
list1.remove("Sweet");
}
if (jComboBox1.getSelectedItem().toString().equals("Chocolate")){
list1.remove("Chocolate");
}
if (jComboBox1.getSelectedItem().toString().equals("Biscuit")){
list1.remove("Biscuit");
}
if (jComboBox1.getSelectedItem().toString().equals("Cake")){
list1.remove("Cake");
}
}
class Item{
//Constructors
Item(String n, int c, double p, int q, String d){
name = n;
code = c;
price = p;
qty = q;
description = d;
}
String name;
int code;
double price;
int qty;
String description;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
ArrayList<String> itemName = new ArrayList<String>(); // name
ArrayList<Integer> itemCode = new ArrayList<Integer>(); // code
ArrayList<Float> itemPrice = new ArrayList<Float>(); // price
ArrayList<Integer> itemQty = new ArrayList<Integer>(); // Quantity
ArrayList<String> itemDescription = new ArrayList<String>(); // Description
ArrayList<String> basketName = new ArrayList<String>(); // name
ArrayList<Integer> basketCode = new ArrayList<Integer>(); // code
ArrayList<Float> basketPrice = new ArrayList<Float>(); // price
ArrayList<Integer> basketQty = new ArrayList<Integer>(); // Quantity
ArrayList<String> basketDescription = new ArrayList<String>(); // Description (optional)
itemName.add("Pen");
itemCode.add(00);
itemPrice.add((float) 1.00);
itemQty.add(20);
itemDescription.add("A nice Pen");
itemName.add("Book");
itemCode.add(01);
itemPrice.add((float) 1.00);
itemQty.add(20);
itemDescription.add("A nice Book");
itemName.add("Water");
itemCode.add(02);
itemPrice.add((float) 1.00);
itemQty.add(20);
itemDescription.add("Good Water");
itemName.add("Drink");
itemCode.add(03);
itemPrice.add((float) 1.00);
itemQty.add(20);
itemDescription.add("A good Drink");
itemName.add("Snack");
itemCode.add(04);
itemPrice.add((float) 2.00);
itemQty.add(20);
itemDescription.add("A nice Snack");
itemName.add("Sweet");
itemCode.add(05);
itemPrice.add((float) 1.00);
itemQty.add(20);
itemDescription.add("A nice Sweet");
itemName.add("Chocolate");
itemCode.add(06);
itemPrice.add((float) 1.00);
itemQty.add(20);
itemDescription.add("A bar of Chocolate");
itemName.add("Biscuit");
itemCode.add(07);
itemPrice.add((float) 1.00);
itemQty.add(20);
itemDescription.add("A packet of Biscuits");
itemName.add("Cake");
itemCode.add(8);
itemPrice.add((float) 2.00);
itemQty.add(20);
itemDescription.add("A slice of Cake");
ArrayList<Item> stocks = new ArrayList<Item>();
ArrayList<Item> basket = new ArrayList<Item>();
//calling Arrays
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ShoppingSystem1().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton11;
private javax.swing.JButton jButton12;
private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JComboBox<String> jComboBox2;
private javax.swing.JFrame jFrame1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private java.awt.List list1;
// End of variables declaration
}
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