diff --git a/RetailSystem.java b/RetailSystem.java new file mode 100644 index 0000000..5c8865d --- /dev/null +++ b/RetailSystem.java @@ -0,0 +1,5214 @@ +package buffer; +import java.awt.Button; +import java.awt.Choice; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Font; +import java.util.*; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.UUID; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.ListIterator; +import java.util.Scanner; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.text.html.HTMLDocument.Iterator; + +import com.sun.jdi.IntegerValue; +import java.awt.Color; +import java.awt.Image; + +class RetailSystem extends JFrame implements ActionListener{ //gui 2 is the first frame, it takes furher to owner and user authetication page + + JButton b1,b2; + JLabel l1,l2,x1; + + RetailSystem() //constructor + { + setSize(1500,1000); // setContentPane(300,300,1366,390); frame size + setLayout(null); + setLocation(0,0); + + l1 = new JLabel(""); + + b2=new JButton("USER"); + b2.setBackground(Color.LIGHT_GRAY); + b2.setForeground(Color.BLACK); + + b1=new JButton("OWNER"); + b1.setBackground(Color.LIGHT_GRAY); + b1.setForeground(Color.BLACK); + + ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/pp.jpg")); + Image i3 = i1.getImage().getScaledInstance(1500, 1000,Image.SCALE_SMOOTH); + ImageIcon i2 = new ImageIcon(i3); + l1 = new JLabel(i2); + //i3.setBounds(0,0,1500,1000); + + + x1=new JLabel("24/7 GROCERY"); + x1.setBounds(480,80,1200,300); + x1.setFont(new Font("Times New Roman",Font.BOLD,65)); + + x1.setForeground(Color.WHITE); + l1.add(x1); + + + b1.setBounds(560,350,250,100); + b2.setBounds(560,500,250,100); + b1.setFont(new Font("Times New Roman",Font.BOLD,35)); + b2.setFont(new Font("Times New Roman",Font.BOLD,35)); + l1.setBounds(0, 0, 1500, 1000); + + l1.add(b1); + add(l1); + + l1.add(b2); + add(l1); + + b1.addActionListener(this); + b2.addActionListener(this); + setVisible(true); + + + + + } + + public void actionPerformed(ActionEvent ae) + { + if(ae.getSource()==b1) + { + Owner f2=new Owner(); + f2.setBounds(0,0,1500,1000); + f2.setVisible(true); + + } + + if(ae.getSource()==b2) + { + User f3=new User(); + f3.setBounds(0,0,1500,1000); + f3.setVisible(true); + + } + + } + public static void main(String args[]) throws IOException //main method,execution starts from here + { + //craete frame and add panel + RetailSystem obj=new RetailSystem(); + obj.setTitle("Online Grocery"); + obj.setBounds(0,0,1500,1000); + obj.setVisible(true); + obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + bigBasket bb=new bigBasket(); + bb.menu(); + stock stk=new stock(); + stk.create_stock(); + System.out.println("Stock added to bst"); + + } + +} + +class Owner extends JFrame implements ActionListener{ //owner authentication page + JButton b3,b4,b5; + TextField t1,t2; + JLabel l1,l2,l3,x1; + + Owner() //takes namd and password + { + super.setTitle("OWNER"); + setLayout(null); + setSize(1500,1000); // setContentPane(300,300,1366,390); frame size + setLayout(null); + setLocation(0,0); + + x1 = new JLabel(""); + + + ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/bg.jpg")); + Image i3 = i1.getImage().getScaledInstance(1500, 1000,Image.SCALE_DEFAULT); + ImageIcon i2 = new ImageIcon(i3); + x1 = new JLabel(i2); + + x1.setBounds(0, 0, 1500, 1000); + add(x1); + + l2=new JLabel("PASSWORD"); //creating components + l3=new JLabel("NAME"); + b3=new JButton("CONTINUE"); + b4=new JButton("BACK"); + l1=new JLabel("OWNER "); + b5=new JButton("OK"); + l1.setBounds(600,50,500,300); + l1.setFont(new Font("Times New Roman",Font.BOLD,50)); //setting bounds + l3.setBounds(50,300,400,50); + l2.setBounds(50,400,400,50); + b5.setBounds(1000,400,200,50); + b3.setBounds(50,500,400,50); + b4.setBounds(50,600,400,50); + + l2.setFont(new Font("Times New Roman",Font.BOLD,30)); + l3.setFont(new Font("Times New Roman",Font.BOLD,30)); + b3.setFont(new Font("Times New Roman",Font.BOLD,30)); + b4.setFont(new Font("Times New Roman",Font.BOLD,30)); + b5.setFont(new Font("Times New Roman",Font.BOLD,30)); + t1=new TextField(50); + t2=new TextField(5); + t1.setFont(new Font("Times New Roman",Font.BOLD,28)); + t2.setFont(new Font("Times New Roman",Font.BOLD,28)); + t2.setEchoChar('*'); + t1.setBounds(500,300,400,50); + t2.setBounds(500,400,400,50); + x1.add(l2); //adding components to container + x1.add(l3); + x1.add(b3); + x1.add(b4); + x1.add(t1); + x1.add(t2); + x1.add(l1); + x1.add(b5); + b5.addActionListener(this); + b3.addActionListener(this); + b4.addActionListener(this); + b3.setEnabled(false); + + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + + } + public void actionPerformed(ActionEvent ae) + { + if(ae.getSource()==b3) + { + //insert into ont of 3 bst + //delete node from bst + //updae field of a node in a bst + //display whole stock + stk_manage sm=new stk_manage(); + sm.setSize(1500,1000); + sm.setVisible(true); + + } + if(ae.getSource()==b4) + { + this.dispose(); + } + if(ae.getSource()==b5) + { + if(t1.getText().equals("Ultron")) + { + if(t2.getText().equals("12345")) + { + b3.setEnabled(true); + } + } + } + } + + + +} + +class stk_manage extends stock implements ActionListener +{ + JButton b1,b2,b3,b4,b5; + TextField t1[]=new TextField[16],t,t2[]=new TextField[20]; //t1-getting quantity + JLabel l1[]=new JLabel[16],l,l2[]=new JLabel[20]; + Choice cb1[]=new Choice[16]; + Choice cb2[]=new Choice[20]; + int y=100; + + stk_manage() + { + Container c=getContentPane(); + c.setLayout(null); + c.setSize(1500,1000); + super.setTitle("Stock, Sales and Delivery"); + //display with a delete button that deleted the product,and update stock button + b2=new JButton("View Cutomer Orders"); //delete product + b3=new JButton("Sales Analysis"); + //ImageIcon icon =new ImageIcon("C:\\Users\\Arvind\\Desktop\\Aastha\\BUFFER\\purple-bedroom-color-ideas.jpg"); + b1=new JButton("Manage Stock"); + //b4=new JButton("Update product details"); + + // Create a panel with buttons and labels and textfields + JPanel panel = new JPanel(null); + + + + b1.setBounds(25,200,500,50); + b2.setBounds(25,300,500,50); + b3.setBounds(25,400,500,50); + //b1.setBounds(25,200,500,50); + + c.add(b1); + + b1.addActionListener(this); + b2.addActionListener(this); + + + } + public void actionPerformed(ActionEvent ae) + { + if(ae.getSource()==b1) + { + //display stock + products p=new products(10); + p.setSize(1500,1000); + p.setVisible(true); + + } + + } + + +} + +class User extends JFrame implements ActionListener //User authentication page +{ + Button b1,b2,b3; + TextField t2,t3,t4,t5,t6; + JLabel l1,l2,l3,l4,l5,l,t,l6,x1; + JCheckBox cb1; + private UUID id; + JButton b; + + + + User() + { + super.setTitle("User"); + setLayout(null); + setSize(1500,1000); // setContentPane(300,300,1366,390); frame size + setLayout(null); + setLocation(0,0); + + x1 = new JLabel(""); + + + ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/bg.jpg")); + Image i3 = i1.getImage().getScaledInstance(1500, 1000,Image.SCALE_DEFAULT); + ImageIcon i2 = new ImageIcon(i3); + x1 = new JLabel(i2); + + x1.setBounds(0, 0, 1500, 1000); + add(x1); + + //this.id+=1; + l=new JLabel("User ID :"); + b=new JButton("OK"); + l1=new JLabel("Login or Create Account"); //login + l2=new JLabel("Username"); //username + l3=new JLabel("Email"); //email + l4=new JLabel("Phone Number"); //phone number + l5=new JLabel("Password"); //password + t2=new TextField(50); //enter username + t3=new TextField(5); //enter email + t4=new TextField(10); //enter phone number + t5=new TextField(10); //enter password + cb1=new JCheckBox("remember me"); //to remembers users data + b1=new Button("Continue"); + + id = UUID.randomUUID(); + + l6=new JLabel(id+""); + // ImageIcon icon =new ImageIcon("C:\\Users\\Arvind\\Desktop\\Aastha\\BUFFER\purple-bedroom-color-ideas.jpg"); + b3=new Button("OK"); + + + //setting bounds + l.setBounds(700,25,150,100); + l6.setBounds(875,25,600,100); + //b.setBounds(800,500,500,100); + //c.add(b); + //t.setBounds(850,50,200,50); + l1.setBounds(50,25,700,100); + l2.setBounds(50,150,400,50); + b3.setBounds(1000,150,100,50); + l3.setBounds(50,250,400,50); + l4.setBounds(50,350,400,50); + l5.setBounds(50,450,400,50); + t2.setBounds(500,150,400,50); + t3.setBounds(500,250,400,50); + t4.setBounds(500,350,400,50); //limit the every tf entry + t5.setBounds(500,450,400,50); + cb1.setBounds(50,550,400,50); + b1.setBounds(500,600,400,50); + + + //fonts + l.setFont(new Font("Times New Roman",Font.BOLD,30)); + l6.setFont(new Font("Times New Roman",Font.PLAIN,15)); + //t.setFont(new Font("Helvetica",Font.BOLD,30)); + l1.setFont(new Font("Times New Roman",Font.BOLD,40)); + l2.setFont(new Font("Times New Roman",Font.PLAIN,30)); + l3.setFont(new Font("Times New Roman",Font.PLAIN,30)); + l4.setFont(new Font("Times New Roman",Font.PLAIN,30)); + l5.setFont(new Font("Times New Roman",Font.PLAIN,30)); + t2.setFont(new Font("Times New Roman",Font.PLAIN,28)); + t3.setFont(new Font("Times New Roman",Font.PLAIN,28)); + t4.setFont(new Font("Times New Roman",Font.PLAIN,28)); + t5.setFont(new Font("Times New Roman",Font.PLAIN,28)); + cb1.setFont(new Font("Times New Roman",Font.PLAIN,20)); + b1.setFont(new Font("Times New Roman",Font.BOLD,28)); + b3.setFont(new Font("Times New Roman",Font.BOLD,28)); + + //to hide the pass + t5.setEchoChar('*'); + + + //add the component6s to the container + x1.add(l); + x1.add(l6); + // c.add(t); + x1.add(l1); + x1.add(l2); + x1.add(l3); + x1.add(l4); + x1.add(l5); + x1.add(t2); + x1.add(t3); + x1.add(t4); + x1.add(t5); + x1.add(cb1); + x1.add(b3); + x1.add(b1); + cb1.addActionListener(this); + + + t2.requestFocusInWindow(); + + b1.addActionListener(this); + b3.addActionListener(this); + b1.setEnabled(false); + + + } + + + public void actionPerformed(ActionEvent ae) + { + boolean flag=true; + if(cb1.getModel().isSelected()) + { + String username=t2.getText(); + //name=username; + String email=t3.getText(); + String ph_no=t4.getText(); + String password=t5.getText(); + String id=l6.getText(); + + cust_queue obj=new cust_queue(); + + obj.cust_queue(id,username,email,ph_no,password); + + } + if(ae.getSource()==b1) + { + + products p1=new products(); + p1.setSize(1500,1000); + p1.setVisible(true); + + } + if(ae.getSource()==b3) + { + String Name=t2.getText(); + for(int i=0;i "); + System.out.println(bb.snacks[i]); + + l1[i]=new JLabel(bb.snacks[i]); //product name + t1[i]=new TextField(5); //to take quantity + b1[i]=new JButton("Delete"); //button to add product to cart + b2[i]=new JButton("Update"); //button to add product to cart + cb1[i]=new Choice(); + cb1[i].add(bb.snacks_quantity[i]+" g ( Rs."+bb.price_snacks[i]+")"); + + } + //set bounds + l.setBounds(25,25,100,50); + t.setBounds(150,25,600,50); + for(int i=0;i "); + System.out.println(bb.bev1[i]); + + l1[i]=new JLabel(bb.bev1[i]); //product name + t1[i]=new TextField(5); //to take quantity + b1[i]=new JButton("Delete"); //button to add product to cart + b2[i]=new JButton("Update"); //button to add product to cart + cb1[i]=new Choice(); + cb1[i].add(bb.quantity_bev1_stock[i]+" Kg ( Rs."+bb.price_bev1[i]+")"); + cb1[i].add(bb.quantity1_bev1_stock[i]+" Kg ( Rs."+bb.price1_bev1[i]+")"); + + } + + for(int i=0;i "); + System.out.println(bb.veggiesFruits[i]); + l1[i]=new JLabel(bb.veggiesFruits[i]); //product name + t1[i]=new TextField(5); //to take quantity + b1[i]=new JButton("Delete"); //button to add product to cart + b2[i]=new JButton("Update"); //button to add product to cart + cb1[i]=new Choice(); + cb1[i].add(bb.quantity_veggie_stock[i]+" Kg ( Rs."+bb.price_vegies[i]+")"); + cb1[i].add(bb.quantity_veggie_stock1[i]+" Kg ( Rs."+bb.price_vegies1[i]+")"); + } + //set bounds + + + for(int i=0;i \n"); + System.out.println("Size -> "+stock.q.size()); + + for(int i=0;i cart=new Hashtable<>(); + static double price; + + beverages() + { + Container c=getContentPane(); + c.setSize(1500,1000); + c.setLayout(null); + // Create a panel with buttons and labels and textfields + JPanel panel = new JPanel(null); + //hardcoded values of products saved in menu of bigBasket class + //search bar + l=new JLabel("SEARCH"); + t=new TextField(50); + b=new JButton("CART"); + ImageIcon icon=new ImageIcon("C:\\Users\\dell\\Documents\\NetBeansProjects\\aastha_buffer\\src\\icons\\iocn.png"); + b5=new JButton("",icon); + + + //add all the products to the page + + for(int i=0;i<16;i++) + { + l1[i]=new JLabel(bb.bev1[i]); //product name + l3[i]=new JLabel("Quantity"); + t1[i]=new TextField(5); //to take quantity + t1[i].setText("1"); + b1[i]=new JButton("Add to cart"); //button to add product to cart + cb1[i]=new Choice(); + cb1[i].add(bb.quantity_bev1_stock[i]+" Kg ( Rs."+bb.price_bev1[i]+")"); + cb1[i].add(bb.quantity1_bev1_stock[i]+" Kg ( Rs."+bb.price1_bev1[i]+")"); + bev1_id[i]=bev_no; + bev_no++; + } + + for(int i=0;i<20;i++) + { + l2[i]=new JLabel(bb.bev2[i]); //product name + t2[i]=new TextField(5); //to take quantity + l4[i]=new JLabel("Quantity"); + b2[i]=new JButton("Add to cart"); //button to add product to cart + cb2[i]=new Choice(); + cb2[i].add(bb.quantity_bev2_stock[i]+" L ( Rs."+bb.price_bev2[i]+")"); + cb2[i].add(bb.quantity1_bev2_stock[i]+" L ( Rs."+bb.price1_bev2[i]+")"); + bev2_id[i]=bev_no; + bev_no++; + } + //set bounds + l.setBounds(25,25,100,50); + t.setBounds(150,25,600,50); + b.setBounds(950,25,200,50); + b5.setBounds(800,25,50,50); + + for(int i=0;i<16;i++) + { + l1[i].setBounds(25,y,200,50); + l3[i].setBounds(350,y+25,100,25); + t1[i].setBounds(500,y+25,200,25); + b1[i].setBounds(800,y+25,200,25); + y+=70; + cb1[i].setBounds(25,y,200,50); + y+=50; + } + for(int i=0;i<20;i++) + { + l2[i].setBounds(25,y,200,50); + l4[i].setBounds(350,y+25,100,25); + t2[i].setBounds(500,y+25,200,25); + b2[i].setBounds(800,y+25,200,25); + y+=70; + cb2[i].setBounds(25,y,200,50); + y+=50; + } + panel.setPreferredSize(new Dimension(1500, y)); + panel.add(l); + panel.add(t); + panel.add(b); + panel.add(b5); + + for(int i=0;i<16;i++) + { + panel.add(l1[i]); + panel.add(cb1[i]); + panel.add(b1[i]); + panel.add(t1[i]); + panel.add(l3[i]); + + } + for(int i=0;i<20;i++) + { + panel.add(l2[i]); + panel.add(cb2[i]); + panel.add(b2[i]); + panel.add(t2[i]); + panel.add(l4[i]); + } + + //add actionListener to each button + for(int i=0;i<16;i++) + { + b1[i].addActionListener(this); + cb1[i].addItemListener(this); + } + + for(int i=0;i<20;i++) + { + b2[i].addActionListener(this); + cb2[i].addItemListener(this); + } + b.addActionListener(this); + b5.addActionListener(this); + //b4.addActionListener(this); + // Add the panel to a scroll pane + + JScrollPane scrollPane = new JScrollPane(panel); + // create scroll pane with panel as the view + scrollPane.setBounds(10, 10, 1300, 700); + c.add(scrollPane); + } + + public void itemStateChanged(ItemEvent e) + { + for(int i=0;i<16;i++) + bev1_choice_index[i]=cb1[i].getSelectedIndex(); + + for(int i=0;i<20;i++) + bev2_choice_index[i]=cb2[i].getSelectedIndex(); + } + + public void actionPerformed(ActionEvent ae) + { + for(int i=0;i<16;i++) + { + if(ae.getSource()==b1[i]) + { + String pro_name=l1[i].getText(); + // add to cart button has been clicked + //add that product in hashtable + + cb1[i].addItemListener(this); + quan1=t1[i].getText(); //in Kg + if(cb1[i].getSelectedIndex()==0) + { + bb.stock_bev1[i]-=Double.parseDouble(quan1)*0.5; + beverages.price+=bb.price_bev1[i]*Double.parseDouble(quan1); + } + + else + { + bb.stock_bev1[i]-=Double.parseDouble(quan1); + beverages.price+=bb.price1_bev1[i]*Double.parseDouble(quan1); + } + + cart.put(bev1_id[i],pro_name); + } + } + + for(int i=0;i<20;i++) + { + if(ae.getSource()==b2[i]) + { + String pro_name=l2[i].getText(); + // add to cart button has been clicked + //add that product in hashtable + cb2[i].addItemListener(this); + quan1=t2[i].getText(); //in Kg + if(cb2[i].getSelectedIndex()==0) + { + bb.stock_bev1[i]-=Double.parseDouble(quan1)*0.5; + + beverages.price+=bb.price_bev2[i]*Double.parseDouble(quan1); + } + + else{ + bb.stock_bev1[i]-=Double.parseDouble(quan1); + beverages.price+=bb.price1_bev2[i]*Double.parseDouble(quan1); + } + cart.put(bev1_id[i],pro_name); + } + } + + + if(ae.getSource()==b5) + { + String search=t.getText(); + stock st=new stock(); + st.create_stock(); + try { + ArrayList str= st.search_bev(search); + bev_search_res bsr=new bev_search_res(str,beverages.cart); + bsr.setSize(1500,1000); + bsr.setVisible(true); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + st.create_stock(); + + + //search is th string to be search in the bst + //Stock stk=new s + } + if(ae.getSource()==b) + { + //cart button is clicked, then show the cart + //we have the data in hashTable, just print the product list on cart page + + Cart c1=new Cart(cart); + c1.setSize(1500,1000); + c1.setVisible(true); + } + if(ae.getSource()==b4) + { + //cart button is clicked, then show the cart + //we have the data in hashTable, just print the product list on cart page + + + LocalDateTime now=LocalDateTime.now(); + //send this new time as login time + + } + + } + +} + +class snaks extends stock implements ActionListener,ItemListener +{ + TextField t1[]=new TextField[16],t; //t1-getting quantity + JLabel l1[]=new JLabel[16],l,l2[]=new JLabel[16]; + Choice cb1[]=new Choice[16]; + JButton b1[]=new JButton[16],b2[]=new JButton[16],b; + JButton b5; + int y=100; + bigBasket bb=new bigBasket(); + int snak_no=36; // beverages starts from number 0 , used for hashing values in hashtable + static int snaks_id[]=new int[16]; + static final int snaks_choice_index[]=new int[16]; + int skip=-1; + int count=0; + static String quan3; + + + snaks() + { + Container c=getContentPane(); + c.setSize(1500,1000); + c.setLayout(null); + // Create a panel with buttons and labels and textfields + JPanel panel = new JPanel(null); + + + + //hardcoded values of products saved in menu of bigBasket class + + //search bar + l=new JLabel("SEARCH"); + + t=new TextField(50); + b=new JButton("CART"); + ImageIcon icon=new ImageIcon("C:\\Users\\dell\\Documents\\NetBeansProjects\\aastha_buffer\\src\\icons\\iocn.png"); + b5=new JButton("",icon); + //add all the products to the page + + for(int i=0;i str= st.search_snaks(search); + //open new page and display all result buttons + snaks_search_res ssr=new snaks_search_res(str,beverages.cart); + ssr.setSize(1500,1000); + ssr.setVisible(true); + } catch (IOException e) { + // TODO Auto-generated catch block + //e.printStackTrace(); + } + st.create_stock(); + } + + + if(ae.getSource()==b) + { + //cart button is clicked, then show the cart + //we have the data in hashTable, just print the product list on cart page + + Cart c1=new Cart(beverages.cart); + c1.setSize(1500,1000); + c1.setVisible(true); + } + + } + +} + +class snaks_search_res extends stock implements ActionListener,ItemListener +{ + TextField t1[]=new TextField[16],t; //t1-getting quantity + JLabel l1[]=new JLabel[16],l; + Choice cb1[]=new Choice[16]; + JButton b1[]=new JButton[16],b; + int y=100; + bigBasket bb=new bigBasket(); + int snak_no=36; // beverages starts from number 0 , used for hashing values in hashtable + int snaks_id[]=new int[16]; + static final int snaks_choice_index[]=new int[16]; + ArrayList al; + int i; + snaks_search_res(ArrayList al,Hashtable cart) + { + + this.al=al; + Container c=getContentPane(); + c.setSize(1500,1000); + c.setLayout(null); + // Create a panel with buttons and labels and textfields + JPanel panel = new JPanel(null); + + bb.menu(); + + //hardcoded values of products saved in menu of bigBasket class + + //search bar + l=new JLabel("Search"); + t=new TextField(50); + b=new JButton("Cart"); + //add all the products to the page + + + for(Object o:al) + { + System.out.println(o.toString()); + l1[i]=new JLabel(o.toString()); //product name + t1[i]=new TextField(5); //to take quantity + b1[i]=new JButton("Add to cart"); //button to add product to cart + cb1[i]=new Choice(); + for(int j=0;j<16;j++) + { + if(o.toString().equals(bb.snacks[j])) + { + + cb1[i].add(bb.snacks_quantity[j]+" g ( Rs."+bb.price_snacks[j]+")"); + break; + } + } + i++; + } + + + //set bounds + l.setBounds(25,25,100,50); + t.setBounds(150,25,600,50); + b.setBounds(1000,25,300,50); + + System.out.println(i); + for(int k=0;k str= st.search_veggies(search); + veggies_search_res vsr=new veggies_search_res(str,beverages.cart); + vsr.setSize(1500,1000); + vsr.setVisible(true); + + } catch (IOException e) { + // TODO Auto-generated catch block + //e.printStackTrace(); + } + st.create_stock(); + } + + if(ae.getSource()==b) + { + //cart button is clicked, then show the cart + //we have the data in hashTable, just print the product list on cart page + + Cart c1=new Cart(beverages.cart); + c1.setSize(1500,1000); + c1.setVisible(true); + } + + } +} + +class veggies_search_res extends stock implements ActionListener,ItemListener +{ + TextField t1[]=new TextField[50],t; //t1-getting quantity + JLabel l1[]=new JLabel[50],l; + Choice cb1[]=new Choice[50]; + JButton b1[]=new JButton[50],b; + int y=100; + bigBasket bb=new bigBasket(); + veggies obj=new veggies(); + //static final int veggies_choice_index[]=new int[16]; + ArrayList al; + int i; + veggies_search_res(ArrayList al,Hashtable cart) + { + + this.al=al; + + Container c=getContentPane(); + c.setSize(1500,1000); + c.setLayout(null); + // Create a panel with buttons and labels and textfields + JPanel panel = new JPanel(null); + + + //hardcoded values of products saved in menu of bigBasket class + + b=new JButton("Cart"); + //add all the products to the page + for(Object o:al) + { + + l1[i]=new JLabel(o.toString()); //product name + t1[i]=new TextField(5); //to take quantity + b1[i]=new JButton("Add to cart"); //button to add product to cart + cb1[i]=new Choice(); + for(int j=0;j<16;j++) + { + + if(o.toString().equals(bb.veggiesFruits[j])) + { + + cb1[i].add(bb.quantity_veggie_stock[j]+" Kg ( Rs."+bb.price_vegies[j]+")"); + cb1[i].add(bb.quantity_veggie_stock1[j]+" Kg ( Rs."+bb.price_vegies1[j]+")"); + break; + } + } + + i++; + } + //set bounds + + b.setBounds(1000,25,300,50); + + + for(int k=0;k"+dest); + + + try + { + confirmation_page cp=new confirmation_page(now,dest); + System.out.println(dest); + cp.setSize(1500,1000); + cp.setVisible(true); + } + catch(IOException e) + { + } + } + } + public void itemStateChanged(ItemEvent ie) + { + if(r1.getModel().isSelected()) + { + //if upi payment open new page + upi u=new upi(); + u.setBounds(400,100,500,500); + u.setVisible(true); + + + } + index=area.getSelectedIndex(); + dest=area.getItem(index); + System.out.println("DEST_> "+dest); + + + + } + + +} + +class confirmation_page extends JFrame +{ + + JLabel l,l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,x1; + LocalDateTime now; + String area; + Calendar cal; + int mins; + String del_time; + JButton b1; + //summary of order + confirmation_page(LocalDateTime now,String dest) throws IOException + { + + System.out.println("Inside confirmation pafe "+dest); + + setSize(1500,1000); // setContentPane(300,300,1366,390); frame size + setLayout(null); + setLocation(0,0); + + x1 = new JLabel(""); + + + ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/confirm.jpg")); + Image i3 = i1.getImage().getScaledInstance(1500, 1000,Image.SCALE_DEFAULT); + ImageIcon i2 = new ImageIcon(i3); + x1 = new JLabel(i2); + + x1.setBounds(0, 0, 1500, 1000); + add(x1); + this.now=now; + this.area=dest; + System.out.println("NOW_> "+now); + System.out.println(area); + packaging p=new packaging(now,"Katraj"); + + mins=p.packaging(); + System.out.println("Mins-> "+mins); + + // ShortestPath sp=new ShortestPath(); + // time t=new time(area); + // t.read(); + cal=Calendar.getInstance(); + + int del_date=cal.get(Calendar.HOUR); + int del_mnt=cal.get(Calendar.MINUTE); + int del_year=cal.get(Calendar.SECOND); + + String del_day=del_date+"-"+del_mnt+"-"+del_year; + //time of order + + cal.add(Calendar.MINUTE,mins); + + int del_date1=cal.get(Calendar.HOUR); + int del_mnt1=cal.get(Calendar.MINUTE); + int del_year1=cal.get(Calendar.SECOND); + int del_date2=cal.get(Calendar.DATE); + int del_mnt2=cal.get(Calendar.MONTH); + int del_year2=cal.get(Calendar.YEAR); + int am_pm=cal.get(Calendar.AM_PM); + String del_day1=del_date1+":"+del_mnt1+":"+del_year1; + + String date=del_date2+"/"+del_mnt2+"/"+del_year2+" "+am_pm; + + //time of delivery + + // String del_day=del_date+"-"+del_mnt+"-"+del_year; + // String s1=cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US); + + // User obj=new User(); + // String name=obj.t2.getText(); + user_data_node node=stock.q.getLast(); + + l=new JLabel("Hello "+node.name); + l1=new JLabel("Area \n\t"+dest); + l2=new JLabel("Your Order is Confirmed!"); ///get the area + l3=new JLabel("Thank you for shopping with us .We'd like to let you know that 24/7 Grocery has received your order."); + + l4=new JLabel("Your estimated delivery date is "+date); + l7=new JLabel("Till "+del_day1); + l8=new JLabel("Total Price :"+ beverages.price); + l9=new JLabel("No Of Items "+beverages.cart.size()); + l10=new JLabel("Thank You!"); + l.setFont(new Font("Times New Roman",Font.BOLD,30)); + l1.setFont(new Font("Times New Roman",Font.BOLD,30)); + l2.setFont(new Font("Times New Roman",Font.BOLD,30)); + l3.setFont(new Font("Times New Roman",Font.PLAIN,30)); + l4.setFont(new Font("Times New Roman",Font.PLAIN,30)); + + + l7.setFont(new Font("Times New Roman",Font.BOLD,30)); + l8.setFont(new Font("Times New Roman",Font.PLAIN,30)); + l9.setFont(new Font("Times New Roman",Font.PLAIN,30)); + l10.setFont(new Font("Times New Roman",Font.PLAIN,30)); + + + + l.setBounds(25,25,300,50); + l1.setBounds(25,100,400,50); + l2.setBounds(25,160,500,50); + l3.setBounds(25,230,1479,50); + l4.setBounds(50,300,800,50); + l7.setBounds(50,375,300,50); + l8.setBounds(25,450,1479,50); + l9.setBounds(50,525,300,50); + l10.setBounds(50,600,300,25); + + + + x1.add(l); + x1.add(l1); + x1.add(l2); + x1.add(l3); + x1.add(l4); + + x1.add(l7); + x1.add(l8); + x1.add(l9); + x1.add(l10); + + + + } + + + +} + + + + +//we need a queue in which we are going to add the data +class node +{ + node next; + String name; + String address; + long ph_no; + String email_add; + String city; + int pincode; + int pay_method; + int offer_code; + double price; + int veggie_no[]=new int[50]; + int beverage_no[]=new int[50]; + String veggie[]=new String[50]; + String beverage[]=new String[50]; + double veggie_quan[]=new double[50]; + int beverage_quan[]=new int[50]; + double veggie_price[]=new double[50]; + double beverage_price[]=new double[50]; + int order_no=0,items; + double quantity_veggie_stock[]=new double[20]; + int quantity_beverage_stock[]=new int[20]; + double savings; +} + +class bigBasket extends JFrame +{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + node front,rear; + static String bev1[]=new String[50]; //array of beverages in Kg + static double price_bev1[] = new double[50]; //each beverage has 2 quantities in g and in kg + static double price1_bev1[] = new double[50]; + static double quantity_bev1_stock[] = new double[50]; + static double quantity1_bev1_stock[] = new double[50]; + static int bev1_pro=16; + + + static String bev2[]=new String[50]; //array of beverages in L + static double price_bev2[] = new double[50]; //each beverage has 2 quantities + static double price1_bev2[] = new double[50]; + static double quantity_bev2_stock[] = new double[50]; //stock of each beverage + static double quantity1_bev2_stock[] = new double[50]; + static int stock_bev1[]=new int[50]; + static int stock_bev2[]=new int[50]; + static int bev2_pro=20; + + + static String snacks[]=new String[50]; + static int snacks_quantity[]=new int[50]; + static double price_snacks[]=new double[50]; + static int stock_snaks[]=new int[50]; + static int snaks_pro=16; + + + static String veggiesFruits[]=new String[50]; //array of beverages in L + static double price_vegies[] = new double[50]; //each beverage has 2 quantities + static double price_vegies1[] = new double[50]; + static double quantity_veggie_stock[] = new double[50]; //stock of each beverage + static double quantity_veggie_stock1[] = new double[50]; + static int stock_veggies[]=new int[50]; + static int veggies_pro=16; + + + bigBasket() + { + front=null; + rear=null; + for(int i=0;i<50;i++) + { + stock_bev1[i]=100; + stock_bev2[i]=100; + stock_snaks[i]=100; //packets quantity + stock_veggies[i]=100; //in kg + } + } + + void menu() + { + + veggiesFruits[0]="Potato"; + quantity_veggie_stock[0]=0.5; + price_vegies[0]=25; + quantity_veggie_stock1[0]=1; + price_vegies1[0]=45; + + veggiesFruits[1]="Carrot"; + quantity_veggie_stock[1]=0.5; + price_vegies[1]=19.50; + quantity_veggie_stock1[1]=1; + price_vegies1[1]=39; + + + + veggiesFruits[2]="Capsicum"; + quantity_veggie_stock[2]=0.5; + price_vegies[2]=42; + quantity_veggie_stock1[2]=1; + price_vegies1[2]=84; + + + + veggiesFruits[3]="Cauliflower"; + + quantity_veggie_stock[3]=0.5; + + price_vegies[3]=20; + + quantity_veggie_stock1[3]=1; + + price_vegies1[3]=35; + + + + veggiesFruits[4]="Capsicum"; + + quantity_veggie_stock[4]=0.5; + + price_vegies[4]=42; + + quantity_veggie_stock1[4]=1; + + price_vegies1[4]=84; + + + + veggiesFruits[5]="Onion"; + + quantity_veggie_stock[5]=1; + + price_vegies[5]=17.5; + + quantity_veggie_stock1[5]=2; + + price_vegies1[5]=35; + + + + veggiesFruits[6]="Ladies' Finger"; + + quantity_veggie_stock[6]=0.25; + + price_vegies[6]=18.5; + + quantity_veggie_stock1[6]=0.5; + + price_vegies1[6]=37; + + + + veggiesFruits[7]="Tomato-Hybrid(Loose)"; + + quantity_veggie_stock[7]=0.5; + + price_vegies[7]=11.5; + + quantity_veggie_stock1[7]=1; + + price_vegies1[7]=23; + + + + veggiesFruits[8]="Cucumber(Loose)"; + + quantity_veggie_stock[8]=0.5; + + price_vegies[8]=13.5; + + quantity_veggie_stock1[8]=1; + + price_vegies1[8]=27; + + + + veggiesFruits[9]="Broccoli"; + + quantity_veggie_stock[9]=0.25; + + price_vegies[9]=15; + + quantity_veggie_stock1[9]=0.5; + + price_vegies1[9]=28; + + + + veggiesFruits[10]="Coriander Leaves"; + + quantity_veggie_stock[10]=0.25; + + price_vegies[10]=32; + + quantity_veggie_stock1[10]=0.5; + + price_vegies1[10]=61; + + + + veggiesFruits[11]="Cabbage"; + + quantity_veggie_stock[11]=0.5; + + price_vegies[11]=14.5; + + quantity_veggie_stock1[11]=1; + + price_vegies1[11]=29; + + + + veggiesFruits[12]="Beetroot"; + + quantity_veggie_stock[12]=0.5; + + price_vegies[12]=14.5; + + quantity_veggie_stock1[12]=1; + + price_vegies1[12]=29; + + + + veggiesFruits[13]="Palak-Cleaned,without roots"; + + quantity_veggie_stock[13]=0.25; + + price_vegies[13]=23; + + quantity_veggie_stock1[13]=1; + + price_vegies1[13]=45; + + + + veggiesFruits[14]="Garlic(Loose)"; + + quantity_veggie_stock[14]=0.1; + + price_vegies[14]=14.5; + + quantity_veggie_stock1[14]=0.5; + + price_vegies1[14]=71.5; + + + + veggiesFruits[15]="Ginger"; + + quantity_veggie_stock[15]=0.1; + + price_vegies[15]=13.5; + + quantity_veggie_stock1[15]=0.5; + + price_vegies1[15]=66.5; + + + bev1[0]="Organic Tea - Tulsi & Ginger"; +quantity_bev1_stock[0]= 0.5; +quantity1_bev1_stock[0]=1; +price_bev1[0]=250; + price1_bev1[0]=420; + bev1[1]="Tea ( Taj Mahal )"; +quantity_bev1_stock[1]= 0.5; +quantity1_bev1_stock[1]=1; +price_bev1[1]=361.50; + price1_bev1[1]=825; + bev1[2]="Orgainc Original Tulsi Tea"; +quantity_bev1_stock[2]= 0.5; +quantity1_bev1_stock[2]=1; +price_bev1[2]=245; + price1_bev1[2]=460; + bev1[3]="Instant Tea - Premix with Ginger"; +quantity_bev1_stock[3]= 0.5; +quantity1_bev1_stock[3]=1; +price_bev1[3]=311.20; + price1_bev1[3]=508.4; + bev1[4]="Tea - Natural Care ( Red Label )"; +quantity_bev1_stock[4]= 0.5; +quantity1_bev1_stock[4]=1; +price_bev1[4]=533; + price1_bev1[4]=286; + bev1[5]="Tea ( Red Label )"; +quantity_bev1_stock[5]= 0.5; +quantity1_bev1_stock[5]=1; +price_bev1[5]=270; + price1_bev1[5]=468; + bev1[6]="Tea ( Society )"; +quantity_bev1_stock[6]= 0.5; +quantity1_bev1_stock[6]=1; +price_bev1[6]=300; + price1_bev1[6]=550; + bev1[7]="Tea ( Tata Tea Gold )"; +quantity_bev1_stock[7]= 0.5; +quantity1_bev1_stock[7]=1; +price_bev1[7]=280; + price1_bev1[7]=680.97; + bev1[8]="Assam Teas ( Tata Tea Gold )"; +quantity_bev1_stock[8]= 0.5; +quantity1_bev1_stock[8]=1; +price_bev1[8]=241; + price1_bev1[8]=474.24; + bev1[9]="Premium Leaf Tea"; +quantity_bev1_stock[9]= 0.5; +quantity1_bev1_stock[9]=1; +price_bev1[9]=251.50; + price1_bev1[9]=565; + bev1[10]="Long Leaf Original Green Tea"; +quantity_bev1_stock[10]= 0.5; +quantity1_bev1_stock[10]=1; +price_bev1[10]=626; + price1_bev1[10]=933; + bev1[11]="Horlicks"; +quantity_bev1_stock[11]= 0.5; +quantity1_bev1_stock[11]=1; +price_bev1[11]=294; + price1_bev1[11]=501; + bev1[12]="Nutritional Powder ( Pediasure )"; +quantity_bev1_stock[12]= 0.5; +quantity1_bev1_stock[12]=1; +price_bev1[12]=690; + price1_bev1[12]=1256; + bev1[13]="Classic Malt ( Horlicks )"; +quantity_bev1_stock[13]= 0.5; +quantity1_bev1_stock[13]=1; +price_bev1[13]=456; + price1_bev1[13]=809; + bev1[14]="Instant Energy Health Drink"; +quantity_bev1_stock[14]= 0.5; +quantity1_bev1_stock[14]=1; +price_bev1[14]=125.10; + price1_bev1[14]=290; + bev1[15]="Chocolate Health Drink - Bournvita"; +quantity_bev1_stock[15]= 0.5; +quantity1_bev1_stock[15]=1; +price_bev1[15]=245; + price1_bev1[15]=490; + bev2[0]="Thums Up"; +quantity_bev2_stock[0]= 0.5; +quantity1_bev2_stock[0]=1; +price_bev2[0]=34; + price1_bev2[0]=65; + bev2[1]="Sparkling Water - Club Soda"; +quantity_bev2_stock[1]= 0.5; +quantity1_bev2_stock[1]=1; +price_bev2[1]=15; + price1_bev2[1]=26.60; + bev2[2]="Soft Drink ( Sprite )"; +quantity_bev2_stock[2]= 0.5; +quantity1_bev2_stock[2]=1; +price_bev2[2]=14.20; + price1_bev2[2]=20; + bev2[3]="Diet Coke Soft Drink"; +quantity_bev2_stock[3]= 0.5; +quantity1_bev2_stock[3]=1; +price_bev2[3]=50; + price1_bev2[3]=87; + bev2[4]="Soft Drink ( Mirinda )"; +quantity_bev2_stock[4]= 0.5; +quantity1_bev2_stock[4]=1; +price_bev2[4]=40; + price1_bev2[4]=80; + bev2[5]="Soda - Original Ginger Ale"; +quantity_bev2_stock[5]= 0.5; +quantity1_bev2_stock[5]=1; +price_bev2[5]=90; + price1_bev2[5]=175; + bev2[6]="Soft Drink - Lime & Lemon Flavoured"; +quantity_bev2_stock[6]= 0.5; +quantity1_bev2_stock[6]=1; +price_bev2[6]=38; + price1_bev2[6]=76; + bev2[7]="Ultra Energy Drink - Zero Sugar ( Monster )"; +quantity_bev2_stock[7]= 0.5; +quantity1_bev2_stock[7]=1; +price_bev2[7]=230; + price1_bev2[7]=460; + bev2[8]="Energy Drink ( Sting )"; +quantity_bev2_stock[8]= 0.5; +quantity1_bev2_stock[8]=1; +price_bev2[8]=40; + price1_bev2[8]=80; + bev2[9]="Soft Drink - Orange Falvoured ( Fanta )"; +quantity_bev2_stock[9]= 0.5; +quantity1_bev2_stock[9]=1; +price_bev2[9]=40; + price1_bev2[9]=68; + bev2[10]="Soft Drink ( Mountain Dew )"; +quantity_bev2_stock[10]= 0.5; +quantity1_bev2_stock[10]=1; +price_bev2[10]=40; + price1_bev2[10]=80; + bev2[11]="Non Alcoholic Beer - Malt"; +quantity_bev2_stock[11]= 0.5; +quantity1_bev2_stock[11]=1; +price_bev2[11]=89; + price1_bev2[11]=178; + bev2[12]="Original Mojito"; +quantity_bev2_stock[12]= 0.5; +quantity1_bev2_stock[12]=1; +price_bev2[12]=175; + price1_bev2[12]=350; + bev2[13]="Kiwi Mojito"; +quantity_bev2_stock[13]= 0.5; +quantity1_bev2_stock[13]=1; +price_bev2[13]=215; + price1_bev2[13]=430; + bev2[14]="Spyci - Masala Maarke ( Bisleri )"; +quantity_bev2_stock[14]= 0.5; +quantity1_bev2_stock[14]=1; +price_bev2[14]=20; + price1_bev2[14]=40; + bev2[15]="Fruit Power Juice - Mixed"; +quantity_bev2_stock[15]= 0.5; +quantity1_bev2_stock[15]=1; +price_bev2[15]=62.5; + price1_bev2[15]=125; + bev2[16]="Fruit Juice - Masala Guava"; +quantity_bev2_stock[16]= 0.5; +quantity1_bev2_stock[16]=1; +price_bev2[16]=35; + price1_bev2[16]=70; + bev2[17]="Rooh Afza Sharbat"; +quantity_bev2_stock[17]= 0.5; +quantity1_bev2_stock[17]=1; +price_bev2[17]=140; + price1_bev2[17]=235; + bev2[18]="Mango Fruit Power Juice"; +quantity_bev2_stock[18]= 0.5; +quantity1_bev2_stock[18]=1; +price_bev2[18]=57; + price1_bev2[18]=115; + bev2[19]="Pomogranate Juice"; +quantity_bev2_stock[19]= 0.5; +quantity1_bev2_stock[19]=1; +price_bev2[19]=270; + price1_bev2[19]=360; + + + + //snaks hardcoded data + + + snacks[0]="Bournville"; + snacks_quantity[0]=80; + price_snacks[0]=95; + + snacks[1]="Minis-Home Treats,Mini Chocolate Bars"; + snacks_quantity[1]=119; + price_snacks[1]=333.5; + + snacks[2]="Chocomini"; + snacks_quantity[2]=250; + price_snacks[2]=140; + + snacks[3]="Maggie"; + snacks_quantity[3]=70; + price_snacks[3]=14; + + + snacks[4]="Cheese Macaroni Pazzta[Maggie]"; + snacks_quantity[4]=70; + price_snacks[4]=32; + + + snacks[5]="Jim Jam Cream Biscuit"; + snacks_quantity[5]=92; + price_snacks[5]=25; + + snacks[6]="Monacco Classic"; + snacks_quantity[6]=800; + price_snacks[6]=120; + + snacks[7]="Bourbon Cream Biscuit"; + snacks_quantity[7]=150; + price_snacks[7]=38; + + snacks[8]="Hide & Seek Chocolate"; + snacks_quantity[8]=100; + price_snacks[8]=30; + + snacks[9]="Kurkure Namkeen-Masala"; + snacks_quantity[9]=70; + price_snacks[9]=54; + + snacks[10]="Lays Potato Chips- American Style Cream & Onion Flavour"; + snacks_quantity[10]=90; + price_snacks[10]=50; + + snacks[11]="Puffcorn[Kurkure]"; + snacks_quantity[11]=55; + price_snacks[11]=20; + + snacks[12]="Mad Angels-Achaari Masti,Crunchy Triangle Chips"; + snacks_quantity[12]=66; + price_snacks[12]=20; + + snacks[13]="Corn Flakes(6)multipack"; + snacks_quantity[13]=65; + price_snacks[13]=102; + + + snacks[14]="Saffola Oats"; + snacks_quantity[14]=1000; + price_snacks[14]=399; + + + snacks[15]="YiPPee! Magic Masala Noodles-Pack of 2"; + snacks_quantity[15]=135; + price_snacks[15]=95.1; + } + + +} + +class node2_bev +{ + node2_bev left,right; + String product; + double quan; +} + +class node2_veggies +{ + node2_veggies left,right; + String product; + double quan; +} + +class node2_snaks +{ + node2_snaks left,right; + String product; + double quan; +} + +class stock extends bigBasket +{ + static node2_bev root; + static node2_veggies root2; + static node2_snaks root3; + String pro; + static LinkedList q=new LinkedList(); + + //this class has information about the stocks available in the class bigBasket + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static node2_bev ptr[]=new node2_bev[36]; + static node2_veggies ptr2[]=new node2_veggies[16]; + static node2_snaks ptr3[]=new node2_snaks[16]; + bigBasket bb=new bigBasket(); + + stock() + { + System.out.println("Called"); + } + void create_stock() + { + //first add all the available quantity stock in binary search tree + + + bb.menu(); + for(int i=0;i0) + curr=curr.left; + else + curr=curr.right; + //cur is the place where node2 is to be added + } + + if((prev.product).compareToIgnoreCase(ptr[i].product)>0) + { + prev.left=ptr[i]; + } + + else + prev.right=ptr[i]; + } + } + for(int i=0;i0) + curr=curr.left; + else + curr=curr.right; + //cur is the place where node2 is to be added + } + if((prev.product).compareToIgnoreCase(ptr2[i].product)>0) + { + prev.left=ptr2[i]; + } + + else + prev.right=ptr2[i]; + } + } + for(int i=0;i0) + curr=curr.left; + else + curr=curr.right; + //cur is the place where node2 is to be added + + } + + if((prev.product).compareToIgnoreCase(ptr3[i].product)>0) + { + prev.left=ptr3[i]; + } + + else + prev.right=ptr3[i]; + } + } + + } + + void delete_veggies(String delete) + { + + node2_veggies cur,prev; + System.out.println("Delete "+delete); + prev=null; + cur=root2; + System.out.println("root2 "+cur.product); + while(cur!=null && !cur.product.trim().contains(delete)) + { + prev=cur; + if((prev.product.toLowerCase()).compareToIgnoreCase(delete.toLowerCase())>0) + cur=cur.left; + else + cur=cur.right; + } + if(cur==null) + { + System.out.println(" Not Found"); + } + else + { + //delete cur + if(cur.left==null && cur.right==null) + { + + //NODE IS LEAF NODE + if(prev==null) + { + //root node is the only node to be deleted + root=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + prev.right=null; + cur=null; + System.out.println("Deleted"); + + } + } + } + else if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root2=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + } + else + { + prev.right=cur.left; + cur.left=null; + System.out.println("Deleted"); + } + } + } + else if(cur.left==null && cur.right!=null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root2=cur.right; + cur.right=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=cur.right; + cur.right=null; + cur=null; + } + else + { + prev.right=cur.right; + cur.right=null; + cur=null; + System.out.println("Deleted"); + + } + } + } + + else if(cur.left!=null && cur.right!=null) + { + node2_veggies temp; + temp=cur; + temp=cur.left; + while(temp.right!=null) + temp=temp.right; + temp.right=cur.right; + cur.right=null; + //now if current has a left subtree + if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root2=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + prev.right=cur.left; + cur.left=null;System.out.println("Deleted");} + }}} + + + } + + bigBasket bb=new bigBasket(); + int index=0; + for(int i=0;i "); + index=i; + + + } + + System.out.println(bb.veggiesFruits[i]); + } + + for(int i=index+1;i0) + cur=cur.left; + else + cur=cur.right; + } + if(cur==null) + { + System.out.println(" jt Not Found"); + } + else + { + //delete cur + if(cur.left==null && cur.right==null) + { + + //NODE IS LEAF NODE + if(prev==null) + { + //root node is the only node to be deleted + root=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + prev.right=null; + cur=null; + System.out.println("Deleted"); + + } + } + } + else if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root3=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + } + else + { + prev.right=cur.left; + cur.left=null; + System.out.println("Deleted"); + } + } + } + else if(cur.left==null && cur.right!=null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root3=cur.right; + cur.right=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=cur.right; + cur.right=null; + cur=null; + + } + else + { + prev.right=cur.right; + cur.right=null; + cur=null; + System.out.println("Deleted"); + + } + } + } + + else if(cur.left!=null && cur.right!=null) + { + node2_snaks temp; + temp=cur; + temp=cur.left; + while(temp.right!=null) + temp=temp.right; + temp.right=cur.right; + cur.right=null; + //now if current has a left subtree + if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root3=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + prev.right=cur.left; + cur.left=null;System.out.println("Deleted");} + }}} + + + } + + bigBasket bb=new bigBasket(); + int index=0; + for(int i=0;i<16;i++) + { + if(bb.snacks[i].equals(delete)) + { + + // bb.snacks[i]=""; + // bb.snacks_quantity[i]=0; + // bb.price_snacks[i]=0; + // bb.stock_snaks[i]=0; + // System.out.println("After deleting inside method satisfying if condition to make that snack null in bigBasket menu -> "); + index=i; + + + } + + System.out.println(bb.snacks[i]); + } + + for(int i=index+1;i<16;i++) + { + bb.snacks[i-1]=bb.snacks[i]; + + } + bb.snaks_pro--; + for(int i=0;i0) + cur=cur.left; + + else + cur=cur.right; + } + + if(cur==null) + { + System.out.println(" Not Found"); + } + else + { + //delete cur + if(cur.left==null && cur.right==null) + { + + //NODE IS LEAF NODE + if(prev==null) + { + //root node is the only node to be deleted + root=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=null; + cur=null; + System.out.println("Deleted"); + } + else + { + prev.right=null; + cur=null; + System.out.println("Deleted"); + + } + } + } + else if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + } + else + { + prev.right=cur.left; + cur.left=null; + System.out.println("Deleted"); + } + } + } + else if(cur.left==null && cur.right!=null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root=cur.right; + cur.right=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=cur.right; + cur.right=null; + cur=null; + + } + else + { + prev.right=cur.right; + cur.right=null; + cur=null; + System.out.println("Deleted"); + + } + } + } + + else if(cur.left!=null && cur.right!=null) + { + node2_bev temp; + temp=cur; + temp=cur.left; + while(temp.right!=null) + temp=temp.right; + temp.right=cur.right; + cur.right=null; + //now if current has a left subtree + if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + } + else + { + if((prev.product).compareToIgnoreCase(delete)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + System.out.println("Deleted"); + + } + else + { + prev.right=cur.left; + cur.left=null;System.out.println("Deleted");} + }}} + } + + bigBasket bb=new bigBasket(); + int index=0,index1=0; + for(int i=0;i "); + index=i; + } + System.out.println(bb.snacks[i]); + } + + + for(int i=index+1;i "); + index1=i; + } + System.out.println(bb.snacks[i]); + } + + for(int i=index1+1;i> STOCK DETAILS -> \n"); + + if(root==null) + System.out.println("YOUR STOCK IS EMPTY !!!"); + + else + { + node2_bev cur; + cur=root; + //inorder traversal of bst -> + + System.out.println("| Product"+"\t\t\t"+"Quantity(kg/pc) |"); + + do + { + while(cur!=null ) + { + top++; + arr[top]=cur; + cur=cur.left; + } + if(top!=-1) + { + cur=arr[top]; + top--; + System.out.println("| "+cur.product+"\t\t"+cur.quan+"\t|"); + cur=cur.right; + } + }while(cur!=null || top!=-1); + + } + } + + void update_snaks(String name,String quan,String price) + { + node2_snaks cur,prev; + System.out.println("UPDATE "+name); + prev=null; + cur=root3; + System.out.println("root3 "+cur.product); + + while(cur!=null && !cur.product.trim().contains(name)) + { + prev=cur; + if((prev.product).compareToIgnoreCase(name)>0) + cur=cur.left; + else + cur=cur.right; + } + if(cur==null) + { + System.out.println(" Not Found"); + } + else + { + //we got the product, just need to be updated + //it is at cur + cur.quan=Double.parseDouble(quan); + for(int i=0;i0) + cur=cur.left; + else + cur=cur.right; + } + if(cur==null) + { + System.out.println(" Not Found"); + } + else + { + //we got the product, just need to be updated + //it is at cur + cur.quan=Double.parseDouble(quan); + for(int i=0;i0) + cur=cur.left; + else + cur=cur.right; + } + if(cur==null) + { + System.out.println(" Not Found"); + } + else + { + //we got the product, just need to be updated + //it is at cur + cur.quan=Double.parseDouble(quan); + for(int i=0;i search_bev(String search) throws IOException + { + bigBasket bb=new bigBasket(); + bb.menu(); + stock st=new stock(); + st.create_stock(); + node2_bev cur,prev; + ArrayList al=new ArrayList(); + + if(root==null) + { + al.add("Not Found"); + return al; + } + else + { + cur=root; + + for(int i=0;i<36;i++) + { + prev=null; + cur=root; + while(cur!=null && !cur.product.toLowerCase().trim().contains(search.toLowerCase())) + { + prev=cur; + if((prev.product.toLowerCase()).compareToIgnoreCase(search.toLowerCase())>0) + cur=cur.left; + else + cur=cur.right; + } + if(cur==null) + { + if(al.isEmpty()) + al.add("Not Found"); + return al; + } + al.add(cur.product); + //cur.product is to be deleted + //node to be deleted is leaf node + if(cur.left==null && cur.right==null) + { + + //NODE IS LEAF NODE + if(prev==null) + { + //root node is the only node to be deleted + root=null; + cur=null; + + } + else + { + if((prev.product.toLowerCase()).compareToIgnoreCase(search.toLowerCase())>0) + { + prev.left=null; + cur=null; + + } + else + { + prev.right=null; + cur=null; + + } + } + } + //node to be deleted has a left subtree + else if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root=cur.left; + cur.left=null; + cur=null; + + } + else + { + if((prev.product.toLowerCase()).compareToIgnoreCase(search.toLowerCase())>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + + } + else + { + prev.right=cur.left; + cur.left=null; + + } + } + } + + else if(cur.left==null && cur.right!=null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root=cur.right; + cur.right=null; + cur=null; + + } + else + { + if((prev.product.toLowerCase()).compareToIgnoreCase(search.toLowerCase())>0) + { + prev.left=cur.right; + cur.right=null; + cur=null; + + } + else + { + prev.right=cur.right; + cur.right=null; + cur=null; + + } + } + } + + else if(cur.left!=null && cur.right!=null) + { + node2_bev temp; + temp=cur; + temp=cur.left; + while(temp.right!=null) + temp=temp.right; + temp.right=cur.right; + cur.right=null; + //now if current has a left subtree + if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root=cur.left; + cur.left=null; + cur=null; + + } + else + { + if((prev.product.toLowerCase()).compareToIgnoreCase(search.toLowerCase())>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + + } + else + { + prev.right=cur.left; + cur.left=null;}}}}} +return al; + } + } + + ArrayList search_veggies(String search) throws IOException +{ + bigBasket bb=new bigBasket(); + bb.menu(); + stock st=new stock(); + st.create_stock(); + node2_veggies cur,prev; + ArrayList al=new ArrayList(); + + + if(root2==null) + { + al.add("Not Found"); + return al; + } + else + { + cur=root2; + + for(int i=0;i<16;i++) + { + prev=null; + cur=root2; + while(cur!=null && !cur.product.toLowerCase().trim().contains(search.toLowerCase())) + { + prev=cur; + if((prev.product.toLowerCase()).compareToIgnoreCase(search.toLowerCase())>0) + cur=cur.left; + else + cur=cur.right; + } + if(cur==null) + { + if(al.isEmpty()) + al.add("Not Found"); + return al; + } + al.add(cur.product); + //cur.product is to be deleted + + + //node to be deleted is leaf node + if(cur.left==null && cur.right==null) + { + + //NODE IS LEAF NODE + if(prev==null) + { + //root node is the only node to be deleted + root=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(search)>0) + { + prev.left=null; + cur=null; + + } + else + { + prev.right=null; + cur=null; + + } + } + } + //node to be deleted has a left subtree + else if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root2=cur.left; + cur.left=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(search)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + + } + else + { + prev.right=cur.left; + cur.left=null; + + } + } + } + + else if(cur.left==null && cur.right!=null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root2=cur.right; + cur.right=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(search)>0) + { + prev.left=cur.right; + cur.right=null; + cur=null; + + } + else + { + prev.right=cur.right; + cur.right=null; + cur=null; + + } + } + } + + else if(cur.left!=null && cur.right!=null) + { + node2_veggies temp; + temp=cur; + temp=cur.left; + while(temp.right!=null) + temp=temp.right; + temp.right=cur.right; + cur.right=null; + //now if current has a left subtree + if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root2=cur.left; + cur.left=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(search)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + + } + else + { + prev.right=cur.left; + cur.left=null;}}}}} +return al; + }} + +ArrayList search_snaks(String search) throws IOException +{ + bigBasket bb=new bigBasket(); + bb.menu(); + stock st=new stock(); + st.create_stock(); + node2_snaks cur,prev; + ArrayList al=new ArrayList(); + + + if(root3==null) + { + al.add("Not Found"); + return al; + } + else + { + cur=root3; + + for(int i=0;i<16;i++) + { + prev=null; + cur=root3; + while(cur!=null && !cur.product.trim().contains(search)) + { + prev=cur; + if((prev.product).compareToIgnoreCase(search)>0) + cur=cur.left; + else + cur=cur.right; + } + if(cur==null) + { + if(al.isEmpty()) + al.add("Not Found"); + return al; + } + al.add(cur.product); + //cur.product is to be deleted + + + //node to be deleted is leaf node + if(cur.left==null && cur.right==null) + { + + //NODE IS LEAF NODE + if(prev==null) + { + //root node is the only node to be deleted + root=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(search)>0) + { + prev.left=null; +cur=null; + + } + else + { + prev.right=null; + cur=null; + + } + } + } + //node to be deleted has a left subtree + else if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root3=cur.left; + cur.left=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(search)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + + } + else + { + prev.right=cur.left; + cur.left=null; + + } + } + } + + else if(cur.left==null && cur.right!=null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root3=cur.right; + cur.right=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(search)>0) + { + prev.left=cur.right; + cur.right=null; + cur=null; + + } + else + { + prev.right=cur.right; + cur.right=null; + cur=null; + + } + } + } + + else if(cur.left!=null && cur.right!=null) + { + node2_snaks temp; + temp=cur; + temp=cur.left; + while(temp.right!=null) + temp=temp.right; + temp.right=cur.right; + cur.right=null; + //now if current has a left subtree + if(cur.left!=null && cur.right==null) + { + if(prev==null) + { + //root node is the only node to be deleted and has a right sub tree + root3=cur.left; + cur.left=null; + cur=null; + + } + else + { + if((prev.product).compareToIgnoreCase(search)>0) + { + prev.left=cur.left; + cur.left=null; + cur=null; + + } + else + { + prev.right=cur.left; + cur.left=null;}}}}} +return al; + }} + + + } + +class packaging{ + LocalDateTime now; + String area; + + packaging(LocalDateTime now,String Area){ + this.now=now; + this.area=Area; + } + + int packaging() { + // LocalDateTime cal=;//now+6 + // int val=cal.compareTo(newnow);//newnow is curr t + // if(val>=0) { // cal>now + // System.out.println("ORDER SHIPPED "); + // } + // else if(val<0) { + // System.out.println("YOUR ORDER IS BEING PACKED "); + // } + + time t=new time(area); + t.readcity(); + int mins=t.read(); + return mins; + } + //int startingpoint= + //des ghe + + } + +class time{ + String shop="Kothrud"; + int shopindex=4; + String Area; + String city[]=new String[15]; + Scanner sc=new Scanner(System.in); + time(String Area){ + this.Area=Area; + } + void readcity(){ + try { + String line=""; + //read text file + BufferedReader br; + br = new BufferedReader(new FileReader("C:\\Users\\dell\\Documents\\NetBeansProjects\\aastha_buffer\\src\\icons\\listofarea.txt")); + int k=0; + while((line=br.readLine())!=null) + { + + city[k]=line; + + k++; + + + } + + }catch (Exception ex) { + System.out.println(ex); + } + } + + + int read(){ + int mins=0; + + try { + + String line=""; + //read text file + BufferedReader br; + br = new BufferedReader(new FileReader("C:\\Users\\dell\\Documents\\NetBeansProjects\\aastha_buffer\\src\\icons\\area.txt")); + //index =index of area array + //row=index of row + //column=index of column + int index=0,row=0,column=0; + String[] area= new String[50]; + boolean flag=false; + int graph[][] = new int[500][500]; + while((line=br.readLine())!=null) + { + // System.out.println(line); + //word[0]=start word[1]=destination word[2]=distance + String w[]=line.split(" "); + + // for(int i=0;i "); + + return totalTime; + } + int dijkstra(int graph[][], int point, String[] area,int dest) throws IOException + { + int time[] = new int[V]; //The output array. + //dist[i] will hold the shortest distance from point to i + + // visited[i] will true if vertex i is included in shortest + + Boolean visited[] = new Boolean[V]; //size 9 + + // Initialize all distances as INFINITE and visited[] as false + for (int i = 0; i < V; i++) { + time[i] = Integer.MAX_VALUE; + visited[i] = false; + } + + // Distance of source vertex from itself is 0 + time[point] = 0; + + // Find shortest path for all vertices + for (int count = 0; count < V - 1; count++) { + // minimum distance vertex from the set of vertices is selected + + int u = minDistance(time, visited); + + // Mark the picked vertex as visited + visited[u] = true; + + // Update dist value of the adjacent vertices of the picked vertex. + for (int v = 0; v < V; v++) + + // Update dist[v] only if is not in dist, there is an edge from u to v, and total weight of path from point to v through u is smaller than current value of dist[v] + if (!visited[v] && graph[u][v] != 0 && time[u] != Integer.MAX_VALUE && time[u] + graph[u][v] < time[v]) + time[v] = time[u] + graph[u][v]; + } + + // print the constructed distance array + int totalTime=printSolution(time, V, area,point, dest); + return totalTime; + + } + } \ No newline at end of file diff --git a/icons.zip b/icons.zip new file mode 100644 index 0000000..fd30987 Binary files /dev/null and b/icons.zip differ