Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exersare.Tabela_unica;
- import Exersare.Clasament_actual;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowEvent;
- import java.awt.event.*;
- import java.sql.*;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class Tabela_unica extends JFrame implements ActionListener {
- private JPanel p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11;//panel intrebari 1-10+cel cu toate intrebarile
- private JButton button1, button2, button3, button4, button5, button6, button7, button8, button9, button10, button11, button12;
- private JButton button13, button14, button15, buttoniesire;//butoane intrebare1
- private JButton button16, button17, button18, buttoniesire2;//butoane intrebare2
- private JButton button19, button20, button21, buttoniesire3;//butoane intrebare3
- private JButton button22, button23, button24, buttoniesire4;//butoane intrebare4
- private JButton button25, button26, button27, buttoniesire5;//butoane intrebare5
- private JButton button28, button29, button30, buttoniesire6;//butoane intrebare6
- private JButton button31, button32, button33, buttoniesire7;//butoane intrebare7
- private JButton button34, button35, button36, buttoniesire8;//butoane intrebare8
- private JButton button37, button38, button39, buttoniesire9;//butoane intrebare9
- private JButton button40, button41, button42, buttoniesire10;//butoane intrebare10
- private JButton rejucare,ierarhie;
- private JLabel l2, l3, l4, l5, l6, l7, l8, l9, l10, l11;//label intrebari1-10
- private JLabel fundali1,fundali2,fundali3,fundali4,fundali5,fundali6,fundali7,fundali8,fundali9,fundali10,fundali11;
- private int nr_click, nr_click2, nr_click3, nr_click4, nr_click5, nr_click6, nr_click7, nr_click8, nr_click9, nr_click10, nr_click11, nr_click12;
- private int nr_click13, nr_click14, nr_click15, nr_click16, nr_click17, nr_click18, nr_click19, nr_click20, nr_click21;//acces button int 1-3
- private int nr_click22, nr_click23, nr_click24, nr_click25, nr_click26, nr_click27, nr_click28, nr_click29, nr_click30;//acces button int 4-6
- private int nr_click31, nr_click32, nr_click33, nr_click34, nr_click35, nr_click36, nr_click37, nr_click38, nr_click39;//acces button int 7-9
- private int nr_click40, nr_click41, nr_click42;//acces button int 10
- private static JLabel l1;
- private static int punctaj, id, punctajbd;
- private String dom, intr1, rasp1, rasp2, rasp3;
- private int corect, corect1, corect2, corect3, corect4, corect5, corect6, corect7, corect8, corect9, corect10;
- private int jocuri, i = 0;
- private int array[] = new int[10];
- boolean gasit = false, semafor = false;
- static boolean salvare_punctaj=false;
- public static JLabel ltimp;
- public static int sfarsit;
- private JButton like1,like2,like3,like4,like5,like6,like7,like8,like9,like10;
- private JButton dlike1,dlike2,dlike3,dlike4,dlike5,dlike6,dlike7,dlike8,dlike9,dlike10;
- private JLabel rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8,rate9,rate10;
- private int id_set_intrebari_adaugate,rating_bd;
- private boolean semafor_like1=false,semafor_like2=false,semafor_like3=false,semafor_like4=false,semafor_like5=false;
- private boolean semafor_like6=false,semafor_like7=false,semafor_like8=false,semafor_like9=false,semafor_like10=false;
- private boolean semafor_dlike1=false,semafor_dlike2=false,semafor_dlike3=false,semafor_dlike4=false,semafor_dlike5=false;
- private boolean semafor_dlike6=false,semafor_dlike7=false,semafor_dlike8=false,semafor_dlike9=false,semafor_dlike10=false;
- private int contor_ia,contor_im,contor_id;
- public Tabela_unica() {
- super("Crezi ca stii?");
- //adaugam panel-ul principal
- p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p1.setLayout(null);
- p1.setVisible(true);
- add(p1);
- fundali1=new JLabel();
- ImagePanel2 fundali1 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Family.jpg").getImage());
- p1.add(fundali1);
- fundali1.setBounds(1,1,752,502);
- fundali1.setLayout(null);
- //adaugam I-ul buton
- button1 = new JButton();
- button1.setBounds(1, 1, 120, 80);
- fundali1.add(button1);
- button1.addActionListener(this);
- //adaugam II-lea buton
- button2 = new JButton();
- button2.setBounds(122, 1, 120, 80);
- fundali1.add(button2);
- button2.addActionListener(this);
- //adaugam III-lea buton
- button3 = new JButton();
- button3.setBounds(243, 1, 120, 80);
- fundali1.add(button3);
- button3.addActionListener(this);
- //adaugam IV-lea buton
- button4 = new JButton();
- button4.setBounds(364, 1, 120, 80);
- fundali1.add(button4);
- button4.addActionListener(this);
- //adaugam al V-lea buton
- button5 = new JButton();
- button5.setBounds(485, 1, 120, 80);
- fundali1.add(button5);
- button5.addActionListener(this);
- //adaugam al VI-lea buton
- button6 = new JButton();
- button6.setBounds(1, 81, 120, 80);
- fundali1.add(button6);
- button6.addActionListener(this);
- //adaugam al VII-lea buton
- button7 = new JButton();
- button7.setBounds(122, 81, 120, 80);
- fundali1.add(button7);
- button7.addActionListener(this);
- //adaugam al VIII-lea buton
- button8 = new JButton();
- button8.setBounds(243, 81, 120, 80);
- fundali1.add(button8);
- button8.addActionListener(this);
- //adaugam al IX-lea buton
- button9 = new JButton();
- button9.setBounds(364, 81, 120, 80);
- fundali1.add(button9);
- button9.addActionListener(this);
- //adaugam al X-lea buton
- button10 = new JButton();
- button10.setBounds(485, 81, 120, 80);
- fundali1.add(button10);
- button10.addActionListener(this);
- //formam al doilea panel+ label+ intrebarile
- p2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p2.setLayout(null);
- fundali2=new JLabel();
- ImagePanel2 fundali2 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p2.add(fundali2);
- fundali2.setBounds(1,1,752,500);
- fundali2.setLayout(null);
- l2 = new JLabel("", SwingConstants.CENTER);
- l2.setBounds(1, 1, 600, 30);
- l2.setOpaque(true);
- l2.setBackground(Color.GRAY);
- l2.setForeground(Color.WHITE);
- fundali2.add(l2);
- like1=new JButton("+1");
- like1.setOpaque(false);
- like1.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like1.setContentAreaFilled(false);
- like1.setBorderPainted(false);
- like1.setBounds(394,150,70,30);
- like1.setLayout(null);
- like1.addActionListener(this);
- fundali2.add(like1);
- like1.setVisible(false);
- rate1=new JLabel("Cum vi s-a parut intrebarea?");
- rate1.setBounds(212,150,188,30);
- rate1.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate1.setOpaque(true);
- rate1.setBackground(Color.GRAY);
- rate1.setForeground(Color.WHITE);
- fundali2.add(rate1);
- rate1.setVisible(false);
- dlike1=new JButton("-1");
- dlike1.setBounds(153,150,70,30);
- dlike1.setOpaque(false);
- dlike1.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike1.setContentAreaFilled(false);
- dlike1.setBorderPainted(false);
- dlike1.addActionListener(this);
- fundali2.add(dlike1);
- dlike1.setVisible(false);
- button13 = new JButton();
- button13.setBounds(1, 31, 600, 31);
- fundali2.add(button13);
- button13.addActionListener(this);
- button14 = new JButton();
- button14.setBounds(1, 62, 600, 31);
- fundali2.add(button14);
- button14.addActionListener(this);
- button15 = new JButton();
- button15.setBounds(1, 93, 600, 31);
- fundali2.add(button15);
- button15.addActionListener(this);
- buttoniesire = new JButton("Inapoi");
- buttoniesire.setBackground(Color.RED);
- fundali2.add(buttoniesire);
- buttoniesire.setBounds(250, 380, 100, 30);
- buttoniesire.addActionListener(this);
- //formam al II-lea panel+ label+ intrebarile
- p3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p3.setLayout(null);
- fundali3=new JLabel();
- ImagePanel2 fundali3 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p3.add(fundali3);
- fundali3.setBounds(1,1,752,500);
- fundali3.setLayout(null);
- like2=new JButton("+1");
- like2.setOpaque(false);
- like2.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like2.setContentAreaFilled(false);
- like2.setBorderPainted(false);
- like2.setBounds(394,150,70,30);
- like2.setLayout(null);
- like2.addActionListener(this);
- fundali3.add(like2);
- like2.setVisible(false);
- rate2=new JLabel("Cum vi s-a parut intrebarea?");
- rate2.setBounds(212,150,188,30);
- rate2.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate2.setOpaque(true);
- rate2.setBackground(Color.GRAY);
- rate2.setForeground(Color.WHITE);
- fundali3.add(rate2);
- rate2.setVisible(false);
- dlike2=new JButton("-1");
- dlike2.setBounds(153,150,70,30);
- dlike2.setOpaque(false);
- dlike2.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike2.setContentAreaFilled(false);
- dlike2.setBorderPainted(false);
- dlike2.addActionListener(this);
- fundali3.add(dlike2);
- dlike2.setVisible(false);
- l3 = new JLabel("", SwingConstants.CENTER);
- l3.setBounds(1, 1, 600, 30);
- l3.setOpaque(true);
- l3.setBackground(Color.GRAY);
- l3.setForeground(Color.WHITE);
- fundali3.add(l3);
- button16 = new JButton();
- button16.setBounds(1, 31, 600, 31);
- fundali3.add(button16);
- button16.addActionListener(this);
- button17 = new JButton();
- button17.setBounds(1, 62, 600, 31);
- fundali3.add(button17);
- button17.addActionListener(this);
- button18 = new JButton();
- button18.setBounds(1, 93, 600, 31);
- fundali3.add(button18);
- button18.addActionListener(this);
- buttoniesire2 = new JButton("Inapoi");
- buttoniesire2.setBackground(Color.RED);
- fundali3.add(buttoniesire2);
- buttoniesire2.setBounds(250, 380, 100, 30);
- buttoniesire2.addActionListener(this);
- //formam al III-lea panel+ label+ intrebarile
- p4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p4.setLayout(null);
- fundali4=new JLabel();
- ImagePanel2 fundali4 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p4.add(fundali4);
- fundali4.setBounds(1,1,752,500);
- fundali4.setLayout(null);
- like3=new JButton("+1");
- like3.setOpaque(false);
- like3.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like3.setContentAreaFilled(false);
- like3.setBorderPainted(false);
- like3.setBounds(394,150,70,30);
- like3.setLayout(null);
- like3.addActionListener(this);
- fundali4.add(like3);
- like3.setVisible(false);
- rate3=new JLabel("Cum vi s-a parut intrebarea?");
- rate3.setBounds(212,150,188,30);
- rate3.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate3.setOpaque(true);
- rate3.setBackground(Color.GRAY);
- rate3.setForeground(Color.WHITE);
- fundali4.add(rate3);
- rate3.setVisible(false);
- dlike3=new JButton("-1");
- dlike3.setBounds(153,150,70,30);
- dlike3.setOpaque(false);
- dlike3.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike3.setContentAreaFilled(false);
- dlike3.setBorderPainted(false);
- dlike3.addActionListener(this);
- fundali4.add(dlike3);
- dlike3.setVisible(false);
- l4 = new JLabel("", SwingConstants.CENTER);
- l4.setBounds(1, 1, 600, 30);
- l4.setOpaque(true);
- l4.setBackground(Color.GRAY);
- l4.setForeground(Color.WHITE);
- fundali4.add(l4);
- button19 = new JButton();
- button19.setBounds(1, 31, 600, 31);
- fundali4.add(button19);
- button19.addActionListener(this);
- button20 = new JButton();
- button20.setBounds(1, 62, 600, 31);
- fundali4.add(button20);
- button20.addActionListener(this);
- button21 = new JButton();
- button21.setBounds(1, 93, 600, 31);
- fundali4.add(button21);
- button21.addActionListener(this);
- buttoniesire3 = new JButton("Inapoi");
- buttoniesire3.setBackground(Color.RED);
- fundali4.add(buttoniesire3);
- buttoniesire3.setBounds(250, 380, 100, 30);
- buttoniesire3.addActionListener(this);
- //formam al IV-lea panel+ label+ intrebarile
- p5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p5.setLayout(null);
- fundali5=new JLabel();
- ImagePanel2 fundali5 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p5.add(fundali5);
- fundali5.setBounds(1,1,752,500);
- fundali5.setLayout(null);
- like4=new JButton("+1");
- like4.setOpaque(false);
- like4.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like4.setContentAreaFilled(false);
- like4.setBorderPainted(false);
- like4.setBounds(394,150,70,30);
- like4.setLayout(null);
- like4.addActionListener(this);
- fundali5.add(like4);
- like4.setVisible(false);
- rate4=new JLabel("Cum vi s-a parut intrebarea?");
- rate4.setBounds(212,150,188,30);
- rate4.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate4.setOpaque(true);
- rate4.setBackground(Color.GRAY);
- rate4.setForeground(Color.WHITE);
- fundali5.add(rate4);
- rate4.setVisible(false);
- dlike4=new JButton("-1");
- dlike4.setBounds(153,150,70,30);
- dlike4.setOpaque(false);
- dlike4.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike4.setContentAreaFilled(false);
- dlike4.setBorderPainted(false);
- dlike4.addActionListener(this);
- fundali5.add(dlike4);
- dlike4.setVisible(false);
- l5 = new JLabel("", SwingConstants.CENTER);
- l5.setBounds(1, 1, 600, 30);
- l5.setOpaque(true);
- l5.setBackground(Color.GRAY);
- l5.setForeground(Color.WHITE);
- fundali5.add(l5);
- button22 = new JButton();
- button22.setBounds(1, 31, 600, 31);
- fundali5.add(button22);
- button22.addActionListener(this);
- button23 = new JButton();
- button23.setBounds(1, 62, 600, 31);
- fundali5.add(button23);
- button23.addActionListener(this);
- button24 = new JButton();
- button24.setBounds(1, 93, 600, 31);
- fundali5.add(button24);
- button24.addActionListener(this);
- buttoniesire4 = new JButton("Inapoi");
- buttoniesire4.setBackground(Color.RED);
- fundali5.add(buttoniesire4);
- buttoniesire4.setBounds(250, 380, 100, 30);
- buttoniesire4.addActionListener(this);
- //formam al V-lea panel+ label+ intrebarile
- p6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p6.setLayout(null);
- fundali6=new JLabel();
- ImagePanel2 fundali6 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p6.add(fundali6);
- fundali6.setBounds(1,1,752,500);
- fundali6.setLayout(null);
- like5=new JButton("+1");
- like5.setOpaque(false);
- like5.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like5.setContentAreaFilled(false);
- like5.setBorderPainted(false);
- like5.setBounds(394,150,70,30);
- like5.setLayout(null);
- like5.addActionListener(this);
- fundali6.add(like5);
- like5.setVisible(false);
- rate5=new JLabel("Cum vi s-a parut intrebarea?");
- rate5.setBounds(212,150,188,30);
- rate5.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate5.setOpaque(true);
- rate5.setBackground(Color.GRAY);
- rate5.setForeground(Color.WHITE);
- fundali6.add(rate5);
- rate5.setVisible(false);
- dlike5=new JButton("-1");
- dlike5.setBounds(153,150,70,30);
- dlike5.setOpaque(false);
- dlike5.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike5.setContentAreaFilled(false);
- dlike5.setBorderPainted(false);
- dlike5.addActionListener(this);
- fundali6.add(dlike5);
- dlike5.setVisible(false);
- l6 = new JLabel("", SwingConstants.CENTER);
- l6.setBounds(1, 1, 600, 30);
- l6.setOpaque(true);
- l6.setBackground(Color.GRAY);
- l6.setForeground(Color.WHITE);
- fundali6.add(l6);
- button25 = new JButton();
- button25.setBounds(1, 31, 600, 31);
- fundali6.add(button25);
- button25.addActionListener(this);
- button26 = new JButton();
- button26.setBounds(1, 62, 600, 31);
- fundali6.add(button26);
- button26.addActionListener(this);
- button27 = new JButton();
- button27.setBounds(1, 93, 600, 31);
- fundali6.add(button27);
- button27.addActionListener(this);
- buttoniesire5 = new JButton("Inapoi");
- buttoniesire5.setBackground(Color.RED);
- fundali6.add(buttoniesire5);
- buttoniesire5.setBounds(250, 380, 100, 30);
- buttoniesire5.addActionListener(this);
- //formam al VI-lea panel+ label+ intrebarile
- p7 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p7.setLayout(null);
- fundali7=new JLabel();
- ImagePanel2 fundali7 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p7.add(fundali7);
- fundali7.setBounds(1,1,752,500);
- fundali7.setLayout(null);
- like6=new JButton("+1");
- like6.setOpaque(false);
- like6.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like6.setContentAreaFilled(false);
- like6.setBorderPainted(false);
- like6.setBounds(394,150,70,30);
- like6.setLayout(null);
- like6.addActionListener(this);
- fundali7.add(like6);
- like6.setVisible(false);
- rate6=new JLabel("Cum vi s-a parut intrebarea?");
- rate6.setBounds(212,150,188,30);
- rate6.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate6.setOpaque(true);
- rate6.setBackground(Color.GRAY);
- rate6.setForeground(Color.WHITE);
- fundali7.add(rate6);
- rate6.setVisible(false);
- dlike6=new JButton("-1");
- dlike6.setBounds(153,150,70,30);
- dlike6.setOpaque(false);
- dlike6.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike6.setContentAreaFilled(false);
- dlike6.setBorderPainted(false);
- dlike6.addActionListener(this);
- fundali7.add(dlike6);
- dlike6.setVisible(false);
- l7 = new JLabel("", SwingConstants.CENTER);
- l7.setBounds(1, 1, 600, 30);
- l7.setOpaque(true);
- l7.setBackground(Color.GRAY);
- l7.setForeground(Color.WHITE);
- fundali7.add(l7);
- button28 = new JButton();
- button28.setBounds(1, 31, 600, 31);
- fundali7.add(button28);
- button28.addActionListener(this);
- button29 = new JButton();
- button29.setBounds(1, 62, 600, 31);
- fundali7.add(button29);
- button29.addActionListener(this);
- button30 = new JButton();
- button30.setBounds(1, 93, 600, 31);
- fundali7.add(button30);
- button30.addActionListener(this);
- buttoniesire6 = new JButton("Inapoi");
- buttoniesire6.setBackground(Color.RED);
- fundali7.add(buttoniesire6);
- buttoniesire6.setBounds(250, 380, 100, 30);
- buttoniesire6.addActionListener(this);
- //formam al VII-lea panel+ label+ intrebarile
- p8 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p8.setLayout(null);
- fundali8=new JLabel();
- ImagePanel2 fundali8 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p8.add(fundali8);
- fundali8.setBounds(1,1,752,500);
- fundali8.setLayout(null);
- like7=new JButton("+1");
- like7.setOpaque(false);
- like7.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like7.setContentAreaFilled(false);
- like7.setBorderPainted(false);
- like7.setBounds(394,150,70,30);
- like7.setLayout(null);
- like7.addActionListener(this);
- fundali8.add(like7);
- like7.setVisible(false);
- rate7=new JLabel("Cum vi s-a parut intrebarea?");
- rate7.setBounds(212,150,188,30);
- rate7.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate7.setOpaque(true);
- rate7.setBackground(Color.GRAY);
- rate7.setForeground(Color.WHITE);
- fundali8.add(rate7);
- rate7.setVisible(false);
- dlike7=new JButton("-1");
- dlike7.setBounds(153,150,70,30);
- dlike7.setOpaque(false);
- dlike7.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike7.setContentAreaFilled(false);
- dlike7.setBorderPainted(false);
- dlike7.addActionListener(this);
- fundali8.add(dlike7);
- dlike7.setVisible(false);
- l8 = new JLabel("", SwingConstants.CENTER);
- l8.setBounds(1, 1, 600, 30);
- l8.setOpaque(true);
- l8.setBackground(Color.GRAY);
- l8.setForeground(Color.WHITE);
- fundali8.add(l8);
- button31 = new JButton();
- button31.setBounds(1, 31, 600, 31);
- fundali8.add(button31);
- button31.addActionListener(this);
- button32 = new JButton();
- button32.setBounds(1, 62, 600, 31);
- fundali8.add(button32);
- button32.addActionListener(this);
- button33 = new JButton();
- button33.setBounds(1, 93, 600, 31);
- fundali8.add(button33);
- button33.addActionListener(this);
- buttoniesire7 = new JButton("Inapoi");
- buttoniesire7.setBackground(Color.RED);
- fundali8.add(buttoniesire7);
- buttoniesire7.setBounds(250, 380, 100, 30);
- buttoniesire7.addActionListener(this);
- //formam al VIII-lea panel+ label+ intrebarile
- p9 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p9.setLayout(null);
- fundali9=new JLabel();
- ImagePanel2 fundali9 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p9.add(fundali9);
- fundali9.setBounds(1,1,752,500);
- fundali9.setLayout(null);
- like8=new JButton("+1");
- like8.setOpaque(false);
- like8.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like8.setContentAreaFilled(false);
- like8.setBorderPainted(false);
- like8.setBounds(394,150,70,30);
- like8.setLayout(null);
- like8.addActionListener(this);
- fundali9.add(like8);
- like8.setVisible(false);
- rate8=new JLabel("Cum vi s-a parut intrebarea?");
- rate8.setBounds(212,150,188,30);
- rate8.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate8.setOpaque(true);
- rate8.setBackground(Color.GRAY);
- rate8.setForeground(Color.WHITE);
- fundali9.add(rate8);
- rate8.setVisible(false);
- dlike8=new JButton("-1");
- dlike8.setBounds(153,150,70,30);
- dlike8.setOpaque(false);
- dlike8.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike8.setContentAreaFilled(false);
- dlike8.setBorderPainted(false);
- dlike8.addActionListener(this);
- fundali9.add(dlike8);
- dlike8.setVisible(false);
- l9 = new JLabel("", SwingConstants.CENTER);
- l9.setBounds(1, 1, 600, 30);
- l9.setOpaque(true);
- l9.setBackground(Color.GRAY);
- l9.setForeground(Color.WHITE);
- fundali9.add(l9);
- button34 = new JButton();
- button34.setBounds(1, 31, 600, 31);
- fundali9.add(button34);
- button34.addActionListener(this);
- button35 = new JButton();
- button35.setBounds(1, 62, 600, 31);
- fundali9.add(button35);
- button35.addActionListener(this);
- button36 = new JButton();
- button36.setBounds(1, 93, 600, 31);
- fundali9.add(button36);
- button36.addActionListener(this);
- buttoniesire8 = new JButton("Inapoi");
- buttoniesire8.setBackground(Color.RED);
- fundali9.add(buttoniesire8);
- buttoniesire8.setBounds(250, 380, 100, 30);
- buttoniesire8.addActionListener(this);
- //formam al IX-lea panel+ label+ intrebarile
- p10 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p10.setLayout(null);
- fundali10=new JLabel();
- ImagePanel2 fundali10 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p10.add(fundali10);
- fundali10.setBounds(1,1,752,500);
- fundali10.setLayout(null);
- like9=new JButton("+1");
- like9.setOpaque(false);
- like9.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like9.setContentAreaFilled(false);
- like9.setBorderPainted(false);
- like9.setBounds(394,150,70,30);
- like9.setLayout(null);
- like9.addActionListener(this);
- fundali10.add(like9);
- like9.setVisible(false);
- rate9=new JLabel("Cum vi s-a parut intrebarea?");
- rate9.setBounds(212,150,188,30);
- rate9.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate9.setOpaque(true);
- rate9.setBackground(Color.GRAY);
- rate9.setForeground(Color.WHITE);
- fundali10.add(rate9);
- rate9.setVisible(false);
- dlike9=new JButton("-1");
- dlike9.setBounds(153,150,70,30);
- dlike9.setOpaque(false);
- dlike9.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike9.setContentAreaFilled(false);
- dlike9.setBorderPainted(false);
- dlike9.addActionListener(this);
- fundali10.add(dlike9);
- dlike9.setVisible(false);
- l10 = new JLabel("", SwingConstants.CENTER);
- l10.setBounds(1, 1, 600, 30);
- l10.setOpaque(true);
- l10.setBackground(Color.GRAY);
- l10.setForeground(Color.WHITE);
- fundali10.add(l10);
- button37 = new JButton();
- button37.setBounds(1, 31, 600, 31);
- fundali10.add(button37);
- button37.addActionListener(this);
- button38 = new JButton();
- button38.setBounds(1, 62, 600, 31);
- fundali10.add(button38);
- button38.addActionListener(this);
- button39 = new JButton();
- button39.setBounds(1, 93, 600, 31);
- fundali10.add(button39);
- button39.addActionListener(this);
- buttoniesire9 = new JButton("Inapoi");
- buttoniesire9.setBackground(Color.RED);
- fundali10.add(buttoniesire9);
- buttoniesire9.setBounds(250, 380, 100, 30);
- buttoniesire9.addActionListener(this);
- //formam al X-lea panel+ label+ intrebarile
- p11 = new JPanel(new FlowLayout(FlowLayout.LEFT));
- p11.setLayout(null);
- fundali11=new JLabel();
- ImagePanel2 fundali11 = new ImagePanel2(new ImageIcon("C:\\Users\\GT\\Desktop\\Imagini\\Log_In2.jpg").getImage());
- p11.add(fundali11);
- fundali11.setBounds(1,1,752,500);
- fundali11.setLayout(null);
- like10=new JButton("+1");
- like10.setOpaque(false);
- like10.setFont(new Font("Arial Black", Font.PLAIN, 15));
- like10.setContentAreaFilled(false);
- like10.setBorderPainted(false);
- like10.setBounds(394,150,70,30);
- like10.setLayout(null);
- fundali11.add(like10);
- like10.addActionListener(this);
- like10.setVisible(false);
- rate10=new JLabel("Cum vi s-a parut intrebarea?");
- rate10.setBounds(212,150,188,30);
- rate10.setFont(new Font("Arial Black", Font.PLAIN, 12));
- rate10.setOpaque(true);
- rate10.setBackground(Color.GRAY);
- rate10.setForeground(Color.WHITE);
- fundali11.add(rate10);
- rate10.setVisible(false);
- dlike10=new JButton("-1");
- dlike10.setBounds(153,150,70,30);
- dlike10.setOpaque(false);
- dlike10.setFont(new Font("Arial Black", Font.PLAIN, 15));
- dlike10.setContentAreaFilled(false);
- dlike10.setBorderPainted(false);
- dlike10.addActionListener(this);
- fundali11.add(dlike10);
- dlike10.setVisible(false);
- l11 = new JLabel("", SwingConstants.CENTER);
- l11.setBounds(1, 1, 600, 30);
- l11.setOpaque(true);
- l11.setBackground(Color.GRAY);
- l11.setForeground(Color.WHITE);
- fundali11.add(l11);
- button40 = new JButton();
- button40.setBounds(1, 31, 600, 31);
- fundali11.add(button40);
- button40.addActionListener(this);
- button41 = new JButton();
- button41.setBounds(1, 62, 600, 31);
- fundali11.add(button41);
- button41.addActionListener(this);
- button42 = new JButton();
- button42.setBounds(1, 93, 600, 31);
- fundali11.add(button42);
- button42.addActionListener(this);
- buttoniesire10 = new JButton("Inapoi");
- buttoniesire10.setBackground(Color.RED);
- fundali11.add(buttoniesire10);
- buttoniesire10.setBounds(250, 380, 100, 30);
- buttoniesire10.addActionListener(this);
- //adaugam labelul pentru a scrie punctajul
- l1 = new JLabel();
- l1.setBounds(130, 425, 250, 20);
- l1.setForeground(Color.WHITE);
- fundali1.add(l1);
- ltimp = new JLabel("Timp ramas :");
- ltimp.setForeground(Color.WHITE);
- ltimp.setBounds(10, 425, 100, 20);
- fundali1.add(ltimp);
- rejucare=new JButton("Incepe alt joc");
- rejucare.setBounds(10,380,150,20);
- fundali1.add(rejucare);
- rejucare.setVisible(false);
- rejucare.addActionListener(this);
- ierarhie=new JButton("Vezi clasament.");
- ierarhie.setBounds(10,350,150,20);
- fundali1.add(ierarhie);
- ierarhie.setVisible(false);
- ierarhie.addActionListener(this);
- addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- int confirmed = JOptionPane.showConfirmDialog(null,
- " Sunteti sigur? ", "Iesire program",
- JOptionPane.YES_NO_OPTION);
- if (confirmed == JOptionPane.YES_OPTION) {
- salvare_punctaj();
- dispose();
- System.exit(0);
- return;
- } else {
- setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
- }
- }
- });
- interogare_joc_id_punctaj();
- nr_jocuri();
- setVisible(true);
- new Timer_tabela(this).start();
- setSize(600, 500);
- setLocationRelativeTo(null);
- setResizable(false);
- }
- public void interogare_joc_id_punctaj() {
- Connection connection;
- PreparedStatement ps;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- ps = connection.prepareStatement("SELECT `Id`,`Jocuri`,`Punctaj` FROM `Utilizatori` WHERE `Utilizator` = ?");
- ps.setString(1, Log_In.t1.getText());
- ResultSet result = ps.executeQuery();
- if (result.next()) {
- id = result.getInt("id");
- jocuri = result.getInt("jocuri");
- punctajbd = result.getInt("punctaj");
- } else {
- JOptionPane.showMessageDialog(null, "Utilizator inexistent !");
- }
- } catch (SQLException ex) {
- Logger.getLogger(Log_In.class.getName()).log(Level.SEVERE, null, ex);
- }
- } //se executa prima
- public void nr_jocuri() {
- switch (jocuri) {
- case 0:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- afiseaza_intrebarea(1);
- break;
- case 1:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- chestionare_rezolvate();
- if (punctajbd <= 40) {
- hai(1);
- }
- if (punctajbd > 40 && (punctajbd) <= 70) {
- hai(4);
- }
- if (punctajbd > 70) {
- hai(7);
- }
- break;
- case 2:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- chestionare_rezolvate();
- if ((punctajbd / 2) <= 40) {
- hai(1);
- }
- if ((punctajbd / 2) > 40 && (punctajbd / 2) <= 70) {
- hai(4);
- }
- if ((punctajbd / 2) > 70) {
- hai(7);
- }
- break;
- case 3:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- chestionare_rezolvate();
- if ((punctajbd / 3) <= 40) {
- hai(1);
- }
- if ((punctajbd / 3) > 40 && (punctajbd / 3) <= 70) {
- hai(4);
- }
- if ((punctajbd / 3) > 70) {
- hai(7);
- }
- break;
- case 4:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- chestionare_rezolvate();
- if ((punctajbd / 4) <= 40) {
- hai(1);
- }
- if ((punctajbd / 4) > 40 && (punctajbd / 4) <= 70) {
- hai(4);
- }
- if ((punctajbd / 4) > 70) {
- hai(7);
- }
- break;
- case 5:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- chestionare_rezolvate();
- if ((punctajbd / 5) <= 40) {
- hai(1);
- }
- if ((punctajbd / 5) > 40 && (punctajbd / 5) <= 70) {
- hai(4);
- }
- if ((punctajbd / 5) > 70) {
- hai(7);
- }
- break;
- case 6:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- chestionare_rezolvate();
- if ((punctajbd / 6) <= 40) {
- hai(1);
- }
- if ((punctajbd / 6) > 40 && (punctajbd / 6) <= 70) {
- hai(4);
- }
- if ((punctajbd / 6) > 70) {
- hai(7);
- }
- break;
- case 7:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- chestionare_rezolvate();
- if ((punctajbd / 7) <= 40) {
- hai(1);
- }
- if ((punctajbd / 7) > 40 && (punctajbd / 7) <= 70) {
- hai(4);
- }
- if ((punctajbd / 7) > 70) {
- hai(7);
- }
- break;
- case 8:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- chestionare_rezolvate();
- if ((punctajbd / 8) <= 40) {
- hai(1);
- }
- if ((punctajbd / 8) > 40 && (punctajbd / 8) <= 70) {
- hai(4);
- }
- if ((punctajbd / 8) > 70) {
- hai(7);
- }
- break;
- case 9:
- jocuri++;
- adaugare_nr_jocuri(jocuri, id);
- chestionare_rezolvate();
- if ((punctajbd / 9) <= 40) {
- hai(1);
- }
- if ((punctajbd / 9) > 40 && (punctajbd / 9) <= 70) {
- hai(4);
- }
- if ((punctajbd / 9) > 70) {
- hai(7);
- }
- break;
- case 10:
- default:
- JOptionPane.showMessageDialog(null, "Vom adauga alte intrebari in curand. O zi buna !");
- System.exit(0);
- }
- } //se executa a doua
- public void adaugare_nr_jocuri(int b, int c) {
- try {
- theQuery2("UPDATE utilizatori SET Jocuri='" + b + "' where id='" + c + "' ");
- } catch (Exception ex) {
- }
- } // se executa pentru a adauga jocul si id-ul in bd
- public void chestionare_rezolvate() {
- Connection connection;
- PreparedStatement ps;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- ps = connection.prepareStatement("SELECT `id_intrebare` FROM `Intrebari_bifate` WHERE `id_user` = '" + id + "'");
- ResultSet result = ps.executeQuery();
- while (result.next()) {
- array[i] = result.getInt("id_intrebare");
- i++;
- }
- } catch (SQLException ex) {
- Logger.getLogger(Tabela_unica.class.getName()).log(Level.SEVERE, null, ex);
- }
- } //calculeaza ce intrebari au fost puse deja
- public void afiseaza_intrebarea(int j) {
- if (j == 1) {
- adaugare_intrebare_utilizata(1);
- afisare(1, 1);
- afisare(2, 2);
- afisare(3, 3);
- afisare(4, 4);
- afisare(5, 5);
- afisare(6, 6);
- afisare(7, 7);
- afisare(8, 8);
- afisare(9, 9);
- afisare(10, 10);
- }
- if (j == 4) {
- adaugare_intrebare_utilizata(4);
- afisare(31, 31);
- afisare(32, 32);
- afisare(33, 33);
- afisare(34, 34);
- afisare(35, 35);
- afisare(36, 36);
- afisare(37, 37);
- afisare(38, 38);
- afisare(39, 39);
- afisare(40, 40);
- }
- if (j == 3) {
- adaugare_intrebare_utilizata(3);
- afisare(21, 21);
- afisare(22, 22);
- afisare(23, 23);
- afisare(24, 24);
- afisare(25, 25);
- afisare(26, 26);
- afisare(27, 27);
- afisare(28, 28);
- afisare(29, 29);
- afisare(30, 30);
- }
- if (j == 2) {
- adaugare_intrebare_utilizata(2);
- afisare(11, 11);
- afisare(12, 12);
- afisare(13, 13);
- afisare(14, 14);
- afisare(15, 15);
- afisare(16, 16);
- afisare(17, 17);
- afisare(18, 18);
- afisare(19, 19);
- afisare(20, 20);
- }
- if (j == 7) {
- adaugare_intrebare_utilizata(7);
- afisare(61, 61);
- afisare(62, 62);
- afisare(63, 63);
- afisare(64, 64);
- afisare(65, 65);
- afisare(66, 66);
- afisare(67, 67);
- afisare(68, 68);
- afisare(69, 69);
- afisare(70, 70);
- }
- if (j == 6) {
- adaugare_intrebare_utilizata(6);
- afisare(51, 51);
- afisare(52, 52);
- afisare(53, 53);
- afisare(54, 54);
- afisare(55, 55);
- afisare(56, 56);
- afisare(57, 57);
- afisare(58, 58);
- afisare(59, 59);
- afisare(60, 60);
- }
- if (j == 5) {
- adaugare_intrebare_utilizata(5);
- afisare(41, 41);
- afisare(42, 42);
- afisare(43, 43);
- afisare(44, 44);
- afisare(45, 45);
- afisare(46, 46);
- afisare(47, 47);
- afisare(48, 48);
- afisare(49, 49);
- afisare(50, 50);
- }
- if (j == 8) {
- adaugare_intrebare_utilizata(8);
- afisare(71, 71);
- afisare(72, 72);
- afisare(73, 73);
- afisare(74, 74);
- afisare(75, 75);
- afisare(76, 76);
- afisare(77, 77);
- afisare(78, 78);
- afisare(79, 79);
- afisare(80, 80);
- }
- if (j == 9) {
- adaugare_intrebare_utilizata(9);
- afisare(81, 81);
- afisare(82, 82);
- afisare(83, 83);
- afisare(84, 84);
- afisare(85, 85);
- afisare(86, 86);
- afisare(87, 87);
- afisare(88, 88);
- afisare(89, 89);
- afisare(90, 90);
- }
- if (j == 10) {
- adaugare_intrebare_utilizata(10);
- afisare(91, 91);
- afisare(92, 92);
- afisare(93, 93);
- afisare(94, 94);
- afisare(95, 95);
- afisare(96, 96);
- afisare(97, 97);
- afisare(98, 98);
- afisare(99, 99);
- afisare(100, 100);
- }
- } //apeleaza functia afisare
- public void afisare(int a, int b) {
- Connection connection;
- PreparedStatement ps;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- ps = connection.prepareStatement("SELECT `Domeniu`,`Intrebare`,`Raspuns1`,`Raspuns2`,`Raspuns3` FROM `Intrebare1` WHERE `id` = '" + a + "'");
- ResultSet result = ps.executeQuery();
- if (result.next()) {
- dom = result.getString("Domeniu");
- intr1 = result.getString("Intrebare");
- rasp1 = result.getString("Raspuns1");
- rasp2 = result.getString("Raspuns2");
- rasp3 = result.getString("Raspuns3");
- corect = 1;
- } else {
- JOptionPane.showMessageDialog(null, "Eroare DB !");
- }
- } catch (SQLException ex) {
- Logger.getLogger(Tabela_unica.class.getName()).log(Level.SEVERE, null, ex);
- }
- if (b == 1) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 2;
- }
- if (b == 2) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 1;
- }
- if (b == 3) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 2;
- }
- if (b == 4) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 3;
- }
- if (b == 5) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 2;
- }
- if (b == 6) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 1;
- }
- if (b == 7) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 3;
- }
- if (b == 8) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 3;
- }
- if (b == 9) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 3;
- }
- if (b == 10) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 2;
- }
- if (b == 11) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 3;
- }
- if (b == 12) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 2;
- }
- if (b == 13) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 3;
- }
- if (b == 14) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 3;
- }
- if (b == 15) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 1;
- }
- if (b == 16) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 3;
- }
- if (b == 17) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 1;
- }
- if (b == 18) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 2;
- }
- if (b == 19) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 2;
- }
- if (b == 20) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 1;
- }
- if (b == 21) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 3;
- }
- if (b == 22) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 3;
- }
- if (b == 23) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 2;
- }
- if (b == 24) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 1;
- }
- if (b == 25) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 2;
- }
- if (b == 26) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 3;
- }
- if (b == 27) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 2;
- }
- if (b == 28) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 1;
- }
- if (b == 29) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 2;
- }
- if (b == 30) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 3;
- }
- if (b == 31) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 2;
- }
- if (b == 32) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 2;
- }
- if (b == 33) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 1;
- }
- if (b == 34) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 1;
- }
- if (b == 35) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 3;
- }
- if (b == 36) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 2;
- }
- if (b == 37) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 2;
- }
- if (b == 38) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 3;
- }
- if (b == 39) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 1;
- }
- if (b == 40) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 3;
- }
- if (b == 41) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 3;
- }
- if (b == 42) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 2;
- }
- if (b == 43) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 3;
- }
- if (b == 44) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 2;
- }
- if (b == 45) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 3;
- }
- if (b == 46) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 2;
- }
- if (b == 47) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 1;
- }
- if (b == 48) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 2;
- }
- if (b == 49) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 3;
- }
- if (b == 50) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 1;
- }
- if (b == 51) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 1;
- }
- if (b == 52) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 1;
- }
- if (b == 53) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 1;
- }
- if (b == 54) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 2;
- }
- if (b == 55) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 3;
- }
- if (b == 56) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 3;
- }
- if (b == 57) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 1;
- }
- if (b == 58) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 3;
- }
- if (b == 59) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 2;
- }
- if (b == 60) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 3;
- }
- if (b == 61) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 1;
- }
- if (b == 62) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 3;
- }
- if (b == 63) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 2;
- }
- if (b == 64) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 3;
- }
- if (b == 65) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 1;
- }
- if (b == 66) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 3;
- }
- if (b == 67) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 1;
- }
- if (b == 68) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 2;
- }
- if (b == 69) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 1;
- }
- if (b == 70) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 2;
- }
- if (b == 71) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 1;
- }
- if (b == 72) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 3;
- }
- if (b == 73) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 1;
- }
- if (b == 74) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 2;
- }
- if (b == 75) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 1;
- }
- if (b == 76) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 3;
- }
- if (b == 77) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 2;
- }
- if (b == 78) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 1;
- }
- if (b == 79) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 1;
- }
- if (b == 80) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 2;
- }
- if (b == 81) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 2;
- }
- if (b == 82) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 2;
- }
- if (b == 83) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 1;
- }
- if (b == 84) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 2;
- }
- if (b == 85) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 3;
- }
- if (b == 86) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 1;
- }
- if (b == 87) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 3;
- }
- if (b == 88) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 2;
- }
- if (b == 39) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 1;
- }
- if (b == 90) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 3;
- }
- if (b == 91) {
- button13.setText(rasp1);
- button14.setText(rasp2);
- button15.setText(rasp3);
- l2.setText(intr1);
- button1.setText(dom);
- corect1 = 1;
- }
- if (b == 92) {
- button16.setText(rasp1);
- button17.setText(rasp2);
- button18.setText(rasp3);
- l3.setText(intr1);
- button2.setText(dom);
- corect2 = 3;
- }
- if (b == 93) {
- button19.setText(rasp1);
- button20.setText(rasp2);
- button21.setText(rasp3);
- l4.setText(intr1);
- button3.setText(dom);
- corect3 = 2;
- }
- if (b == 94) {
- button22.setText(rasp1);
- button23.setText(rasp2);
- button24.setText(rasp3);
- l5.setText(intr1);
- button4.setText(dom);
- corect4 = 2;
- }
- if (b == 95) {
- button25.setText(rasp1);
- button26.setText(rasp2);
- button27.setText(rasp3);
- l6.setText(intr1);
- button5.setText(dom);
- corect5 = 3;
- }
- if (b == 96) {
- button28.setText(rasp1);
- button29.setText(rasp2);
- button30.setText(rasp3);
- l7.setText(intr1);
- button6.setText(dom);
- corect6 = 1;
- }
- if (b == 97) {
- button31.setText(rasp1);
- button32.setText(rasp2);
- button33.setText(rasp3);
- l8.setText(intr1);
- button7.setText(dom);
- corect7 = 2;
- }
- if (b == 98) {
- button34.setText(rasp1);
- button35.setText(rasp2);
- button36.setText(rasp3);
- l9.setText(intr1);
- button8.setText(dom);
- corect8 = 3;
- }
- if (b == 99) {
- button37.setText(rasp1);
- button38.setText(rasp2);
- button39.setText(rasp3);
- l10.setText(intr1);
- button9.setText(dom);
- corect9 = 1;
- }
- if (b == 100) {
- button40.setText(rasp1);
- button41.setText(rasp2);
- button42.setText(rasp3);
- l11.setText(intr1);
- button10.setText(dom);
- corect10 = 3;
- }
- }//afiseaza intrebarile in functie de parametrii a=id, b=datele si id ul intrebarii
- public void hai(int p) {
- p++;
- int j = 0;
- gasit = false;
- if (p == 10) {
- p = 2;
- }
- for (int k = 0; k < array.length; k++) {
- j++;
- if (array[k] == p) {
- gasit = true;
- hai(p);
- } else {
- if (j == array.length && gasit == false && semafor == false) {
- afiseaza_intrebarea(p);
- semafor = true;
- }
- }
- }
- } //apeleaza functia afiseaza_intrebarea
- public void adaugare_intrebare_utilizata(int a) {
- try {
- theQuery2("insert into intrebari_bifate (id_intrebare,id_user) values('" + a + "','" + id + "')");
- } catch (Exception ex) {
- }
- id_set_intrebari_adaugate=a;
- }//adauga in bd id_intrebare si id-ul userului
- public void rating_plus(int x){
- if(id_set_intrebari_adaugate==1){
- }
- if(id_set_intrebari_adaugate==2){
- x=x+10;
- }
- if(id_set_intrebari_adaugate==3){
- x=x+20;
- }
- if(id_set_intrebari_adaugate==4){
- x=x+30;
- }
- if(id_set_intrebari_adaugate==5){
- x=x+40;
- }
- if(id_set_intrebari_adaugate==6){
- x=x+50;
- }
- if(id_set_intrebari_adaugate==7){
- x=x+60;
- }
- if(id_set_intrebari_adaugate==8){
- x=x+70;
- }
- if(id_set_intrebari_adaugate==9){
- x=x+80;
- }
- if(id_set_intrebari_adaugate==10){
- x=x+90;
- }
- Connection connection;
- PreparedStatement ps;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- ps = connection.prepareStatement("SELECT `Rating` FROM `Intrebare1` WHERE `id` = '" + x + "'");
- ResultSet result = ps.executeQuery();
- if (result.next()) {
- rating_bd = result.getInt("Rating");
- } else {
- JOptionPane.showMessageDialog(null, "Eroare DB !");
- }
- } catch (SQLException ex) {
- Logger.getLogger(Tabela_unica.class.getName()).log(Level.SEVERE, null, ex);
- }
- rating_bd++;
- adaugare_rating(rating_bd,x);
- }
- public void rating_minus(int x){
- if(id_set_intrebari_adaugate==1){
- }
- if(id_set_intrebari_adaugate==2){
- x=x+10;
- }
- if(id_set_intrebari_adaugate==3){
- x=x+20;
- }
- if(id_set_intrebari_adaugate==4){
- x=x+30;
- }
- if(id_set_intrebari_adaugate==5){
- x=x+40;
- }
- if(id_set_intrebari_adaugate==6){
- x=x+50;
- }
- if(id_set_intrebari_adaugate==7){
- x=x+60;
- }
- if(id_set_intrebari_adaugate==8){
- x=x+70;
- }
- if(id_set_intrebari_adaugate==9){
- x=x+80;
- }
- if(id_set_intrebari_adaugate==10){
- x=x+90;
- }
- Connection connection;
- PreparedStatement ps;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- ps = connection.prepareStatement("SELECT `Rating` FROM `Intrebare1` WHERE `id` = '" + x + "'");
- ResultSet result = ps.executeQuery();
- if (result.next()) {
- rating_bd = result.getInt("Rating");
- } else {
- JOptionPane.showMessageDialog(null, "Eroare DB !");
- }
- } catch (SQLException ex) {
- Logger.getLogger(Tabela_unica.class.getName()).log(Level.SEVERE, null, ex);
- }
- rating_bd--;
- adaugare_rating(rating_bd,x);
- verificare_rating(rating_bd,x);
- }
- public void verificare_rating(int a,int b) {
- if (a == -5) {
- if (b <= 40) {
- Connection connection;
- PreparedStatement ps;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- ps = connection.prepareStatement("SELECT `Rating` FROM `Intrebare1` WHERE `id` = '" + 101 + "'");
- ResultSet result = ps.executeQuery();
- if (result.next()) {
- contor_ia = result.getInt("Rating");
- } else {
- JOptionPane.showMessageDialog(null, "Eroare DB !");
- }
- } catch (SQLException ex) {
- Logger.getLogger(Tabela_unica.class.getName()).log(Level.SEVERE, null, ex);
- }
- if (contor_ia >4) {
- contor_ia++;
- try {
- theQuery2("update intrebare1 set rating='" + contor_ia + "' where id='" + 101 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_ia == 4) {
- contor_ia++;
- try {
- theQuery2("update intrebare1 set id='" + 125 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_ia + "' where id='" + 101 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_ia == 3) {
- contor_ia++;
- try {
- theQuery2("update intrebare1 set id='" + 124 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_ia + "' where id='" + 101 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_ia == 2) {
- contor_ia++;
- try {
- theQuery2("update intrebare1 set id='" + 123 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_ia + "' where id='" + 101 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_ia == 1) {
- contor_ia++;
- try {
- theQuery2("update intrebare1 set id='" + 122 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_ia + "' where id='" + 101 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_ia == 0) {
- contor_ia++;
- try {
- theQuery2("update intrebare1 set id='" + 121 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_ia + "' where id='" + 101 + "'");
- } catch (Exception ex) {
- }
- }
- }
- if (b > 40 && b<=70) {
- Connection connection;
- PreparedStatement ps;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- ps = connection.prepareStatement("SELECT `Rating` FROM `Intrebare1` WHERE `id` = '" + 102 + "'");
- ResultSet result = ps.executeQuery();
- if (result.next()) {
- contor_im = result.getInt("Rating");
- } else {
- JOptionPane.showMessageDialog(null, "Eroare DB !");
- }
- } catch (SQLException ex) {
- Logger.getLogger(Tabela_unica.class.getName()).log(Level.SEVERE, null, ex);
- }
- if (contor_im >4) {
- contor_im++;
- try {
- theQuery2("update intrebare1 set rating='" + contor_im + "' where id='" + 102 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_im == 4) {
- contor_im++;
- try {
- theQuery2("update intrebare1 set id='" + 130 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_im + "' where id='" + 102 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_im == 3) {
- contor_im++;
- try {
- theQuery2("update intrebare1 set id='" + 129 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_im + "' where id='" + 102 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_im == 2) {
- contor_im++;
- try {
- theQuery2("update intrebare1 set id='" + 128 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_im + "' where id='" + 102 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_im == 1) {
- contor_im++;
- try {
- theQuery2("update intrebare1 set id='" + 127 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_im + "' where id='" + 102 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_im == 0) {
- contor_im++;
- try {
- theQuery2("update intrebare1 set id='" + 126 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_im + "' where id='" + 102 + "'");
- } catch (Exception ex) {
- }
- }
- }
- if (b > 70) {
- Connection connection;
- PreparedStatement ps;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- ps = connection.prepareStatement("SELECT `Rating` FROM `Intrebare1` WHERE `id` = '" + 103 + "'");
- ResultSet result = ps.executeQuery();
- if (result.next()) {
- contor_id = result.getInt("Rating");
- } else {
- JOptionPane.showMessageDialog(null, "Eroare DB !");
- }
- } catch (SQLException ex) {
- Logger.getLogger(Tabela_unica.class.getName()).log(Level.SEVERE, null, ex);
- }
- if (contor_id >4) {
- contor_id++;
- try {
- theQuery2("update intrebare1 set rating='" + contor_id + "' where id='" + 103 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_id == 4) {
- contor_id++;
- try {
- theQuery2("update intrebare1 set id='" + 135 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_id + "' where id='" + 103 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_id == 3) {
- contor_id++;
- try {
- theQuery2("update intrebare1 set id='" + 134 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_id + "' where id='" + 103 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_id == 2) {
- contor_id++;
- try {
- theQuery2("update intrebare1 set id='" + 133 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_id + "' where id='" + 103 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_id == 1) {
- contor_id++;
- try {
- theQuery2("update intrebare1 set id='" + 132 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_id + "' where id='" + 103 + "'");
- } catch (Exception ex) {
- }
- }
- if (contor_id == 0) {
- contor_id++;
- try {
- theQuery2("update intrebare1 set id='" + 131 + "' where id='" + b + "'");
- theQuery2("update intrebare1 set rating='" + contor_id + "' where id='" + 103 + "'");
- } catch (Exception ex) {
- }
- }
- }
- }
- }
- public void adaugare_rating(int a, int b) {
- try {
- theQuery2("update intrebare1 set rating='" + a + "' where id='" + b + "'");
- } catch (Exception ex) {
- }
- }
- public static void theQuery(String query) {
- Connection con = null;
- Statement st = null;
- try {
- con = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- st = con.createStatement();
- st.executeUpdate(query);
- } catch (SQLException | HeadlessException ex) {
- JOptionPane.showMessageDialog(null, ex.getMessage());
- }
- }
- public void actionPerformed(ActionEvent ev) {
- if (ev.getSource() == button1)
- if (nr_click >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p2);
- remove(p1);
- revalidate();
- repaint();
- nr_click++;
- }
- if (ev.getSource() == button2) {
- if (nr_click2 >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p3);
- remove(p1);
- revalidate();
- repaint();
- nr_click2++;
- }
- }
- if (ev.getSource() == button3) {
- if (nr_click3 >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p4);
- remove(p1);
- revalidate();
- repaint();
- nr_click3++;
- }
- }
- if (ev.getSource() == button4) {
- if (nr_click4 >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p5);
- remove(p1);
- revalidate();
- repaint();
- nr_click4++;
- }
- }
- if (ev.getSource() == button5) {
- if (nr_click5 >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p6);
- remove(p1);
- revalidate();
- repaint();
- nr_click5++;
- }
- }
- if (ev.getSource() == button6) {
- if (nr_click6 >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p7);
- remove(p1);
- revalidate();
- repaint();
- nr_click6++;
- }
- }
- if (ev.getSource() == button7) {
- if (nr_click7 >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p8);
- remove(p1);
- revalidate();
- repaint();
- nr_click7++;
- }
- }
- if (ev.getSource() == button8) {
- if (nr_click8 >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p9);
- remove(p1);
- revalidate();
- repaint();
- nr_click8++;
- }
- }
- if (ev.getSource() == button9) {
- if (nr_click9 >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p10);
- remove(p1);
- revalidate();
- repaint();
- nr_click9++;
- }
- }
- if (ev.getSource() == button10) {
- if (nr_click10 >= 1)
- JOptionPane.showMessageDialog(null, "Domeniu ales deja !");
- else {
- add(p11);
- remove(p1);
- revalidate();
- repaint();
- nr_click10++;
- }
- }
- if (ev.getSource() == button13) {
- nr_click13++;
- like1.setVisible(true);
- rate1.setVisible(true);
- dlike1.setVisible(true);
- buttoniesire.setBackground(Color.GREEN);
- if (corect1 == 1) {
- if (nr_click13 == 1) {
- button1.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button13.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click14++;
- nr_click15++;
- }
- }
- if (corect1 == 2) {
- if (nr_click13 == 1) {
- button1.setBackground(Color.RED);
- button14.setBackground(Color.GREEN);
- button13.setBackground(Color.RED);
- button1.setForeground(Color.WHITE);
- nr_click14++;
- nr_click15++;
- }
- }
- if (corect1 == 3) {
- if (nr_click13 == 1) {
- button1.setBackground(Color.RED);
- button15.setBackground(Color.GREEN);
- button13.setBackground(Color.RED);
- button1.setForeground(Color.WHITE);
- nr_click14++;
- nr_click15++;
- }
- }
- }
- if (ev.getSource() == button14) {
- buttoniesire.setBackground(Color.GREEN);
- nr_click14++;
- like1.setVisible(true);
- rate1.setVisible(true);
- dlike1.setVisible(true);
- if (corect1 == 1) {
- if (nr_click14 == 1) {
- button1.setForeground(Color.WHITE);
- button1.setBackground(Color.RED);
- button13.setBackground(Color.GREEN);
- button14.setBackground(Color.RED);
- nr_click13++;
- nr_click15++;
- }
- }
- if (corect1 == 2) {
- if (nr_click14 == 1) {
- button1.setBackground(Color.GREEN);
- button14.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click13++;
- nr_click15++;
- }
- }
- if (corect1 == 3) {
- if (nr_click14 == 1) {
- button1.setForeground(Color.WHITE);
- button1.setBackground(Color.RED);
- button15.setBackground(Color.GREEN);
- button14.setBackground(Color.RED);
- nr_click13++;
- nr_click15++;
- }
- }
- }
- if (ev.getSource() == button15) {
- nr_click15++;
- like1.setVisible(true);
- rate1.setVisible(true);
- dlike1.setVisible(true);
- buttoniesire.setBackground(Color.GREEN);
- if (corect1 == 1) {
- if (nr_click15 == 1) {
- button1.setForeground(Color.WHITE);
- button1.setBackground(Color.RED);
- button13.setBackground(Color.GREEN);
- button15.setBackground(Color.RED);
- nr_click13++;
- nr_click14++;
- }
- }
- if (corect1 == 2) {
- if (nr_click15 == 1) {
- button1.setForeground(Color.WHITE);
- button1.setBackground(Color.RED);
- button14.setBackground(Color.GREEN);
- button15.setBackground(Color.RED);
- nr_click13++;
- nr_click14++;
- }
- }
- if (corect1 == 3) {
- if (nr_click15 == 1) {
- button1.setBackground(Color.GREEN);
- button15.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click13++;
- nr_click14++;
- }
- }
- }
- if (ev.getSource() == buttoniesire) {
- if (nr_click13 > 0 || nr_click14 > 0 || nr_click15 > 0) {
- add(p1);
- remove(p2);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (ev.getSource() == button16) {
- nr_click16++;
- like2.setVisible(true);
- rate2.setVisible(true);
- dlike2.setVisible(true);
- buttoniesire2.setBackground(Color.GREEN);
- if (corect2 == 1) {
- if (nr_click16 == 1) {
- button2.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button16.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click17++;
- nr_click18++;
- }
- }
- if (corect2 == 2) {
- if (nr_click16 == 1) {
- button2.setBackground(Color.RED);
- button17.setBackground(Color.GREEN);
- button16.setBackground(Color.RED);
- button2.setForeground(Color.WHITE);
- nr_click17++;
- nr_click18++;
- }
- }
- if (corect2 == 3) {
- if (nr_click16 == 1) {
- button2.setBackground(Color.RED);
- button18.setBackground(Color.GREEN);
- button16.setBackground(Color.RED);
- button2.setForeground(Color.WHITE);
- nr_click17++;
- nr_click18++;
- }
- }
- }
- if (ev.getSource() == button17) {
- buttoniesire2.setBackground(Color.GREEN);
- nr_click17++;
- like2.setVisible(true);
- rate2.setVisible(true);
- dlike2.setVisible(true);
- if (corect2 == 1) {
- if (nr_click17 == 1) {
- button2.setForeground(Color.WHITE);
- button2.setBackground(Color.RED);
- button16.setBackground(Color.GREEN);
- button17.setBackground(Color.RED);
- nr_click16++;
- nr_click18++;
- }
- }
- if (corect2 == 2) {
- if (nr_click17 == 1) {
- button2.setBackground(Color.GREEN);
- button17.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click16++;
- nr_click18++;
- }
- }
- if (corect2 == 3) {
- if (nr_click17 == 1) {
- button2.setForeground(Color.WHITE);
- button2.setBackground(Color.RED);
- button18.setBackground(Color.GREEN);
- button17.setBackground(Color.RED);
- nr_click16++;
- nr_click18++;
- }
- }
- }
- if (ev.getSource() == button18) {
- nr_click18++;
- like2.setVisible(true);
- rate2.setVisible(true);
- dlike2.setVisible(true);
- buttoniesire2.setBackground(Color.GREEN);
- if (corect2 == 1) {
- if (nr_click18 == 1) {
- button2.setForeground(Color.WHITE);
- button2.setBackground(Color.RED);
- button16.setBackground(Color.GREEN);
- button18.setBackground(Color.RED);
- nr_click16++;
- nr_click17++;
- }
- }
- if (corect2 == 2) {
- if (nr_click18 == 1) {
- button2.setForeground(Color.WHITE);
- button2.setBackground(Color.RED);
- button17.setBackground(Color.GREEN);
- button18.setBackground(Color.RED);
- nr_click16++;
- nr_click17++;
- }
- }
- if (corect2 == 3) {
- if (nr_click18 == 1) {
- button2.setBackground(Color.GREEN);
- button18.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click16++;
- nr_click17++;
- }
- }
- }
- if (ev.getSource() == buttoniesire2) {
- if (nr_click16 > 0 || nr_click17 > 0 || nr_click18 > 0) {
- add(p1);
- remove(p3);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (ev.getSource() == button19) {
- nr_click19++;
- like3.setVisible(true);
- rate3.setVisible(true);
- dlike3.setVisible(true);
- buttoniesire3.setBackground(Color.GREEN);
- if (corect3 == 1) {
- if (nr_click19 == 1) {
- button3.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button19.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click20++;
- nr_click21++;
- }
- }
- if (corect3 == 2) {
- if (nr_click19 == 1) {
- button3.setBackground(Color.RED);
- button20.setBackground(Color.GREEN);
- button19.setBackground(Color.RED);
- button3.setForeground(Color.WHITE);
- nr_click20++;
- nr_click21++;
- }
- }
- if (corect3 == 3) {
- if (nr_click19 == 1) {
- button3.setBackground(Color.RED);
- button21.setBackground(Color.GREEN);
- button19.setBackground(Color.RED);
- button3.setForeground(Color.WHITE);
- nr_click20++;
- nr_click21++;
- }
- }
- }
- if (ev.getSource() == button20) {
- buttoniesire3.setBackground(Color.GREEN);
- like3.setVisible(true);
- rate3.setVisible(true);
- dlike3.setVisible(true);
- nr_click20++;
- if (corect3 == 1) {
- if (nr_click20 == 1) {
- button3.setForeground(Color.WHITE);
- button3.setBackground(Color.RED);
- button19.setBackground(Color.GREEN);
- button20.setBackground(Color.RED);
- nr_click19++;
- nr_click21++;
- }
- }
- if (corect3 == 2) {
- if (nr_click20 == 1) {
- button3.setBackground(Color.GREEN);
- button20.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click19++;
- nr_click21++;
- }
- }
- if (corect3 == 3) {
- if (nr_click20 == 1) {
- button3.setForeground(Color.WHITE);
- button3.setBackground(Color.RED);
- button21.setBackground(Color.GREEN);
- button20.setBackground(Color.RED);
- nr_click19++;
- nr_click21++;
- }
- }
- }
- if (ev.getSource() == button21) {
- nr_click21++;
- like3.setVisible(true);
- rate3.setVisible(true);
- dlike3.setVisible(true);
- buttoniesire3.setBackground(Color.GREEN);
- if (corect3 == 1) {
- if (nr_click21 == 1) {
- button3.setForeground(Color.WHITE);
- button3.setBackground(Color.RED);
- button19.setBackground(Color.GREEN);
- button21.setBackground(Color.RED);
- nr_click19++;
- nr_click20++;
- }
- }
- if (corect3 == 2) {
- if (nr_click21 == 1) {
- button3.setForeground(Color.WHITE);
- button3.setBackground(Color.RED);
- button20.setBackground(Color.GREEN);
- button21.setBackground(Color.RED);
- nr_click19++;
- nr_click20++;
- }
- }
- if (corect3 == 3) {
- if (nr_click21 == 1) {
- button3.setBackground(Color.GREEN);
- button21.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click19++;
- nr_click20++;
- }
- }
- }
- if (ev.getSource() == buttoniesire3) {
- if (nr_click19 > 0 || nr_click20 > 0 || nr_click21 > 0) {
- add(p1);
- remove(p4);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (ev.getSource() == button22) {
- nr_click22++;
- like4.setVisible(true);
- rate4.setVisible(true);
- dlike4.setVisible(true);
- buttoniesire4.setBackground(Color.GREEN);
- if (corect4 == 1) {
- if (nr_click22 == 1) {
- button4.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button22.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click23++;
- nr_click24++;
- }
- }
- if (corect4 == 2) {
- if (nr_click22 == 1) {
- button4.setBackground(Color.RED);
- button23.setBackground(Color.GREEN);
- button22.setBackground(Color.RED);
- button4.setForeground(Color.WHITE);
- nr_click23++;
- nr_click24++;
- }
- }
- if (corect4 == 3) {
- if (nr_click22 == 1) {
- button4.setBackground(Color.RED);
- button24.setBackground(Color.GREEN);
- button22.setBackground(Color.RED);
- button4.setForeground(Color.WHITE);
- nr_click23++;
- nr_click24++;
- }
- }
- }
- if (ev.getSource() == button23) {
- buttoniesire4.setBackground(Color.GREEN);
- nr_click23++;
- like4.setVisible(true);
- rate4.setVisible(true);
- dlike4.setVisible(true);
- if (corect4 == 1) {
- if (nr_click23 == 1) {
- button4.setForeground(Color.WHITE);
- button4.setBackground(Color.RED);
- button22.setBackground(Color.GREEN);
- button23.setBackground(Color.RED);
- nr_click22++;
- nr_click24++;
- }
- }
- if (corect4 == 2) {
- if (nr_click23 == 1) {
- button4.setBackground(Color.GREEN);
- button23.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click22++;
- nr_click24++;
- }
- }
- if (corect4 == 3) {
- if (nr_click23 == 1) {
- button4.setForeground(Color.WHITE);
- button4.setBackground(Color.RED);
- button24.setBackground(Color.GREEN);
- button23.setBackground(Color.RED);
- nr_click22++;
- nr_click24++;
- }
- }
- }
- if (ev.getSource() == button24) {
- nr_click24++;
- like4.setVisible(true);
- rate4.setVisible(true);
- dlike4.setVisible(true);
- buttoniesire4.setBackground(Color.GREEN);
- if (corect4 == 1) {
- if (nr_click24 == 1) {
- button4.setForeground(Color.WHITE);
- button4.setBackground(Color.RED);
- button22.setBackground(Color.GREEN);
- button24.setBackground(Color.RED);
- nr_click22++;
- nr_click23++;
- }
- }
- if (corect4 == 2) {
- if (nr_click24 == 1) {
- button4.setForeground(Color.WHITE);
- button4.setBackground(Color.RED);
- button23.setBackground(Color.GREEN);
- button24.setBackground(Color.RED);
- nr_click22++;
- nr_click23++;
- }
- }
- if (corect4 == 3) {
- if (nr_click24 == 1) {
- button4.setBackground(Color.GREEN);
- button24.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click22++;
- nr_click23++;
- }
- }
- }
- if (ev.getSource() == buttoniesire4) {
- if (nr_click22 > 0 || nr_click23 > 0 || nr_click24 > 0) {
- add(p1);
- remove(p5);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (ev.getSource() == button25) {
- nr_click25++;
- like5.setVisible(true);
- rate5.setVisible(true);
- dlike5.setVisible(true);
- buttoniesire5.setBackground(Color.GREEN);
- if (corect5 == 1) {
- if (nr_click25 == 1) {
- button5.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button25.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click26++;
- nr_click27++;
- }
- }
- if (corect5 == 2) {
- if (nr_click25 == 1) {
- button5.setBackground(Color.RED);
- button26.setBackground(Color.GREEN);
- button25.setBackground(Color.RED);
- button5.setForeground(Color.WHITE);
- nr_click26++;
- nr_click27++;
- }
- }
- if (corect5 == 3) {
- if (nr_click25 == 1) {
- button5.setBackground(Color.RED);
- button27.setBackground(Color.GREEN);
- button25.setBackground(Color.RED);
- button5.setForeground(Color.WHITE);
- nr_click26++;
- nr_click27++;
- }
- }
- }
- if (ev.getSource() == button26) {
- buttoniesire5.setBackground(Color.GREEN);
- nr_click26++;
- like5.setVisible(true);
- rate5.setVisible(true);
- dlike5.setVisible(true);
- if (corect5 == 1) {
- if (nr_click26 == 1) {
- button5.setForeground(Color.WHITE);
- button5.setBackground(Color.RED);
- button25.setBackground(Color.GREEN);
- button26.setBackground(Color.RED);
- nr_click25++;
- nr_click27++;
- }
- }
- if (corect5 == 2) {
- if (nr_click26 == 1) {
- button5.setBackground(Color.GREEN);
- button26.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click25++;
- nr_click27++;
- }
- }
- if (corect5 == 3) {
- if (nr_click26 == 1) {
- button5.setForeground(Color.WHITE);
- button5.setBackground(Color.RED);
- button27.setBackground(Color.GREEN);
- button26.setBackground(Color.RED);
- nr_click25++;
- nr_click27++;
- }
- }
- }
- if (ev.getSource() == button27) {
- nr_click27++;
- like5.setVisible(true);
- rate5.setVisible(true);
- dlike5.setVisible(true);
- buttoniesire5.setBackground(Color.GREEN);
- if (corect5 == 1) {
- if (nr_click27 == 1) {
- button5.setForeground(Color.WHITE);
- button5.setBackground(Color.RED);
- button25.setBackground(Color.GREEN);
- button27.setBackground(Color.RED);
- nr_click25++;
- nr_click26++;
- }
- }
- if (corect5 == 2) {
- if (nr_click27 == 1) {
- button5.setForeground(Color.WHITE);
- button5.setBackground(Color.RED);
- button26.setBackground(Color.GREEN);
- button27.setBackground(Color.RED);
- nr_click25++;
- nr_click26++;
- }
- }
- if (corect5 == 3) {
- if (nr_click27 == 1) {
- button5.setBackground(Color.GREEN);
- button27.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click25++;
- nr_click26++;
- }
- }
- }
- if (ev.getSource() == buttoniesire5) {
- if (nr_click25 > 0 || nr_click26 > 0 || nr_click27 > 0) {
- add(p1);
- remove(p6);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (ev.getSource() == button28) {
- nr_click28++;
- like6.setVisible(true);
- rate6.setVisible(true);
- dlike6.setVisible(true);
- buttoniesire6.setBackground(Color.GREEN);
- if (corect6 == 1) {
- if (nr_click28 == 1) {
- button6.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button28.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click29++;
- nr_click30++;
- }
- }
- if (corect6 == 2) {
- if (nr_click28 == 1) {
- button6.setBackground(Color.RED);
- button29.setBackground(Color.GREEN);
- button28.setBackground(Color.RED);
- button6.setForeground(Color.WHITE);
- nr_click29++;
- nr_click30++;
- }
- }
- if (corect6 == 3) {
- if (nr_click28 == 1) {
- button6.setBackground(Color.RED);
- button30.setBackground(Color.GREEN);
- button28.setBackground(Color.RED);
- button6.setForeground(Color.WHITE);
- nr_click29++;
- nr_click30++;
- }
- }
- }
- if (ev.getSource() == button29) {
- buttoniesire6.setBackground(Color.GREEN);
- nr_click29++;
- like6.setVisible(true);
- rate6.setVisible(true);
- dlike6.setVisible(true);
- if (corect6 == 1) {
- if (nr_click29 == 1) {
- button6.setForeground(Color.WHITE);
- button6.setBackground(Color.RED);
- button28.setBackground(Color.GREEN);
- button29.setBackground(Color.RED);
- nr_click28++;
- nr_click30++;
- }
- }
- if (corect6 == 2) {
- if (nr_click29 == 1) {
- button6.setBackground(Color.GREEN);
- button29.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click28++;
- nr_click30++;
- }
- }
- if (corect6 == 3) {
- if (nr_click29 == 1) {
- button6.setForeground(Color.WHITE);
- button6.setBackground(Color.RED);
- button30.setBackground(Color.GREEN);
- button29.setBackground(Color.RED);
- nr_click28++;
- nr_click30++;
- }
- }
- }
- if (ev.getSource() == button30) {
- nr_click30++;
- like6.setVisible(true);
- rate6.setVisible(true);
- dlike6.setVisible(true);
- buttoniesire6.setBackground(Color.GREEN);
- if (corect6 == 1) {
- if (nr_click30 == 1) {
- button6.setForeground(Color.WHITE);
- button6.setBackground(Color.RED);
- button28.setBackground(Color.GREEN);
- button30.setBackground(Color.RED);
- nr_click28++;
- nr_click29++;
- }
- }
- if (corect6 == 2) {
- if (nr_click30 == 1) {
- button6.setForeground(Color.WHITE);
- button6.setBackground(Color.RED);
- button29.setBackground(Color.GREEN);
- button30.setBackground(Color.RED);
- nr_click28++;
- nr_click29++;
- }
- }
- if (corect6 == 3) {
- if (nr_click30 == 1) {
- button6.setBackground(Color.GREEN);
- button30.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click28++;
- nr_click29++;
- }
- }
- }
- if (ev.getSource() == buttoniesire6) {
- if (nr_click28 > 0 || nr_click29 > 0 || nr_click30 > 0) {
- add(p1);
- remove(p7);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (ev.getSource() == button31) {
- nr_click31++;
- like7.setVisible(true);
- rate7.setVisible(true);
- dlike7.setVisible(true);
- buttoniesire7.setBackground(Color.GREEN);
- if (corect7 == 1) {
- if (nr_click31 == 1) {
- button7.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button31.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click32++;
- nr_click33++;
- }
- }
- if (corect7 == 2) {
- if (nr_click31 == 1) {
- button7.setBackground(Color.RED);
- button32.setBackground(Color.GREEN);
- button31.setBackground(Color.RED);
- button7.setForeground(Color.WHITE);
- nr_click32++;
- nr_click33++;
- }
- }
- if (corect7 == 3) {
- if (nr_click31 == 1) {
- button7.setBackground(Color.RED);
- button33.setBackground(Color.GREEN);
- button31.setBackground(Color.RED);
- button7.setForeground(Color.WHITE);
- nr_click32++;
- nr_click33++;
- }
- }
- }
- if (ev.getSource() == button32) {
- buttoniesire7.setBackground(Color.GREEN);
- nr_click32++;
- like7.setVisible(true);
- rate7.setVisible(true);
- dlike7.setVisible(true);
- if (corect7 == 1) {
- if (nr_click32 == 1) {
- button7.setForeground(Color.WHITE);
- button7.setBackground(Color.RED);
- button31.setBackground(Color.GREEN);
- button32.setBackground(Color.RED);
- nr_click31++;
- nr_click33++;
- }
- }
- if (corect7 == 2) {
- if (nr_click32 == 1) {
- button7.setBackground(Color.GREEN);
- button32.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click31++;
- nr_click33++;
- }
- }
- if (corect7 == 3) {
- if (nr_click32 == 1) {
- button7.setForeground(Color.WHITE);
- button7.setBackground(Color.RED);
- button33.setBackground(Color.GREEN);
- button32.setBackground(Color.RED);
- nr_click31++;
- nr_click33++;
- }
- }
- }
- if (ev.getSource() == button33) {
- nr_click33++;
- like7.setVisible(true);
- rate7.setVisible(true);
- dlike7.setVisible(true);
- buttoniesire7.setBackground(Color.GREEN);
- if (corect7 == 1) {
- if (nr_click33 == 1) {
- button7.setForeground(Color.WHITE);
- button7.setBackground(Color.RED);
- button31.setBackground(Color.GREEN);
- button33.setBackground(Color.RED);
- nr_click31++;
- nr_click32++;
- }
- }
- if (corect7 == 2) {
- if (nr_click33 == 1) {
- button7.setForeground(Color.WHITE);
- button7.setBackground(Color.RED);
- button32.setBackground(Color.GREEN);
- button33.setBackground(Color.RED);
- nr_click31++;
- nr_click32++;
- }
- }
- if (corect7 == 3) {
- if (nr_click33 == 1) {
- button7.setBackground(Color.GREEN);
- button33.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click31++;
- nr_click32++;
- }
- }
- }
- if (ev.getSource() == buttoniesire7) {
- if (nr_click31 > 0 || nr_click32 > 0 || nr_click33 > 0) {
- add(p1);
- remove(p8);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (ev.getSource() == button34) {
- nr_click34++;
- like8.setVisible(true);
- rate8.setVisible(true);
- dlike8.setVisible(true);
- buttoniesire8.setBackground(Color.GREEN);
- if (corect8 == 1) {
- if (nr_click34 == 1) {
- button8.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button34.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click35++;
- nr_click36++;
- }
- }
- if (corect8 == 2) {
- if (nr_click34 == 1) {
- button8.setBackground(Color.RED);
- button35.setBackground(Color.GREEN);
- button34.setBackground(Color.RED);
- button8.setForeground(Color.WHITE);
- nr_click35++;
- nr_click36++;
- }
- }
- if (corect8 == 3) {
- if (nr_click34 == 1) {
- button8.setBackground(Color.RED);
- button36.setBackground(Color.GREEN);
- button34.setBackground(Color.RED);
- button8.setForeground(Color.WHITE);
- nr_click35++;
- nr_click36++;
- }
- }
- }
- if (ev.getSource() == button35) {
- buttoniesire8.setBackground(Color.GREEN);
- nr_click35++;
- like8.setVisible(true);
- rate8.setVisible(true);
- dlike8.setVisible(true);
- if (corect8 == 1) {
- if (nr_click35 == 1) {
- button8.setForeground(Color.WHITE);
- button8.setBackground(Color.RED);
- button34.setBackground(Color.GREEN);
- button35.setBackground(Color.RED);
- nr_click34++;
- nr_click36++;
- }
- }
- if (corect8 == 2) {
- if (nr_click35 == 1) {
- button8.setBackground(Color.GREEN);
- button35.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click34++;
- nr_click36++;
- }
- }
- if (corect8 == 3) {
- if (nr_click35 == 1) {
- button8.setForeground(Color.WHITE);
- button8.setBackground(Color.RED);
- button36.setBackground(Color.GREEN);
- button35.setBackground(Color.RED);
- nr_click34++;
- nr_click36++;
- }
- }
- }
- if (ev.getSource() == button36) {
- nr_click36++;
- like8.setVisible(true);
- rate8.setVisible(true);
- dlike8.setVisible(true);
- buttoniesire8.setBackground(Color.GREEN);
- if (corect8 == 1) {
- if (nr_click36 == 1) {
- button8.setForeground(Color.WHITE);
- button8.setBackground(Color.RED);
- button34.setBackground(Color.GREEN);
- button36.setBackground(Color.RED);
- nr_click34++;
- nr_click35++;
- }
- }
- if (corect8 == 2) {
- if (nr_click36 == 1) {
- button8.setForeground(Color.WHITE);
- button8.setBackground(Color.RED);
- button35.setBackground(Color.GREEN);
- button36.setBackground(Color.RED);
- nr_click34++;
- nr_click35++;
- }
- }
- if (corect8 == 3) {
- if (nr_click36 == 1) {
- button8.setBackground(Color.GREEN);
- button36.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click34++;
- nr_click35++;
- }
- }
- }
- if (ev.getSource() == buttoniesire8) {
- if (nr_click34 > 0 || nr_click35 > 0 || nr_click36 > 0) {
- add(p1);
- remove(p9);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (ev.getSource() == button37) {
- nr_click37++;
- like9.setVisible(true);
- rate9.setVisible(true);
- dlike9.setVisible(true);
- buttoniesire9.setBackground(Color.GREEN);
- if (corect9 == 1) {
- if (nr_click37 == 1) {
- button9.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button37.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click38++;
- nr_click39++;
- }
- }
- if (corect9 == 2) {
- if (nr_click37 == 1) {
- button9.setBackground(Color.RED);
- button38.setBackground(Color.GREEN);
- button37.setBackground(Color.RED);
- button9.setForeground(Color.WHITE);
- nr_click38++;
- nr_click39++;
- }
- }
- if (corect9 == 3) {
- if (nr_click37 == 1) {
- button9.setBackground(Color.RED);
- button39.setBackground(Color.GREEN);
- button37.setBackground(Color.RED);
- button9.setForeground(Color.WHITE);
- nr_click38++;
- nr_click39++;
- }
- }
- }
- if (ev.getSource() == button38) {
- buttoniesire9.setBackground(Color.GREEN);
- nr_click38++;
- like9.setVisible(true);
- rate9.setVisible(true);
- dlike9.setVisible(true);
- if (corect9 == 1) {
- if (nr_click38 == 1) {
- button9.setForeground(Color.WHITE);
- button9.setBackground(Color.RED);
- button37.setBackground(Color.GREEN);
- button38.setBackground(Color.RED);
- nr_click37++;
- nr_click39++;
- }
- }
- if (corect9 == 2) {
- if (nr_click38 == 1) {
- button9.setBackground(Color.GREEN);
- button38.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click37++;
- nr_click39++;
- }
- }
- if (corect9 == 3) {
- if (nr_click38 == 1) {
- button9.setForeground(Color.WHITE);
- button9.setBackground(Color.RED);
- button39.setBackground(Color.GREEN);
- button38.setBackground(Color.RED);
- nr_click37++;
- nr_click39++;
- }
- }
- }
- if (ev.getSource() == button39) {
- nr_click39++;
- like9.setVisible(true);
- rate9.setVisible(true);
- dlike9.setVisible(true);
- buttoniesire9.setBackground(Color.GREEN);
- if (corect9 == 1) {
- if (nr_click39 == 1) {
- button9.setForeground(Color.WHITE);
- button9.setBackground(Color.RED);
- button37.setBackground(Color.GREEN);
- button39.setBackground(Color.RED);
- nr_click37++;
- nr_click38++;
- }
- }
- if (corect9 == 2) {
- if (nr_click39 == 1) {
- button9.setForeground(Color.WHITE);
- button9.setBackground(Color.RED);
- button38.setBackground(Color.GREEN);
- button39.setBackground(Color.RED);
- nr_click37++;
- nr_click38++;
- }
- }
- if (corect9 == 3) {
- if (nr_click39 == 1) {
- button9.setBackground(Color.GREEN);
- button39.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click37++;
- nr_click38++;
- }
- }
- }
- if (ev.getSource() == buttoniesire9) {
- if (nr_click37 > 0 || nr_click38 > 0 || nr_click39 > 0) {
- add(p1);
- remove(p10);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (ev.getSource() == button40) {
- nr_click40++;
- like10.setVisible(true);
- rate10.setVisible(true);
- dlike10.setVisible(true);
- buttoniesire10.setBackground(Color.GREEN);
- if (corect10 == 1) {
- if (nr_click40 == 1) {
- button10.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- button40.setBackground(Color.GREEN);
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click41++;
- nr_click42++;
- }
- }
- if (corect10 == 2) {
- if (nr_click40 == 1) {
- button10.setBackground(Color.RED);
- button41.setBackground(Color.GREEN);
- button40.setBackground(Color.RED);
- button10.setForeground(Color.WHITE);
- nr_click41++;
- nr_click42++;
- }
- }
- if (corect10 == 3) {
- if (nr_click40 == 1) {
- button10.setBackground(Color.RED);
- button42.setBackground(Color.GREEN);
- button40.setBackground(Color.RED);
- button10.setForeground(Color.WHITE);
- nr_click41++;
- nr_click42++;
- }
- }
- }
- if (ev.getSource() == button41) {
- buttoniesire10.setBackground(Color.GREEN);
- nr_click41++;
- like10.setVisible(true);
- rate10.setVisible(true);
- dlike10.setVisible(true);
- if (corect10 == 1) {
- if (nr_click41 == 1) {
- button10.setForeground(Color.WHITE);
- button10.setBackground(Color.RED);
- button40.setBackground(Color.GREEN);
- button41.setBackground(Color.RED);
- nr_click40++;
- nr_click42++;
- }
- }
- if (corect10 == 2) {
- if (nr_click41 == 1) {
- button10.setBackground(Color.GREEN);
- button41.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click40++;
- nr_click42++;
- }
- }
- if (corect10 == 3) {
- if (nr_click41 == 1) {
- button10.setForeground(Color.WHITE);
- button10.setBackground(Color.RED);
- button42.setBackground(Color.GREEN);
- button41.setBackground(Color.RED);
- nr_click40++;
- nr_click42++;
- }
- }
- }
- if (ev.getSource() == button42) {
- nr_click42++;
- like10.setVisible(true);
- rate10.setVisible(true);
- dlike10.setVisible(true);
- buttoniesire10.setBackground(Color.GREEN);
- if (corect10 == 1) {
- if (nr_click42 == 1) {
- button10.setForeground(Color.WHITE);
- button10.setBackground(Color.RED);
- button40.setBackground(Color.GREEN);
- button42.setBackground(Color.RED);
- nr_click40++;
- nr_click41++;
- }
- }
- if (corect10 == 2) {
- if (nr_click42 == 1) {
- button10.setForeground(Color.WHITE);
- button10.setBackground(Color.RED);
- button41.setBackground(Color.GREEN);
- button42.setBackground(Color.RED);
- nr_click40++;
- nr_click41++;
- }
- }
- if (corect10 == 3) {
- if (nr_click42 == 1) {
- button10.setBackground(Color.GREEN);
- button42.setBackground(Color.GREEN);
- punctaj = punctaj + 10;
- Tabela_unica.l1.setText("Aveti " + punctaj + " puncte.");
- nr_click40++;
- nr_click41++;
- }
- }
- }
- if (ev.getSource() == buttoniesire10) {
- if (nr_click40 > 0 || nr_click41 > 0 || nr_click42 > 0) {
- add(p1);
- remove(p11);
- revalidate();
- repaint();
- sfarsit++;
- } else {
- JOptionPane.showMessageDialog(null, "Alegeti o varianta de raspuns !");
- }
- }
- if (sfarsit == 10) {
- JOptionPane.showMessageDialog(null, " Jocul s-a incheiat !");
- salvare_punctaj();
- rejucare.setVisible(true);
- ierarhie.setVisible(true);
- sfarsit++;
- }
- if (ev.getSource() == rejucare) {
- JOptionPane.showMessageDialog(null, "Rejucam !");
- dispose();
- sfarsit=0;
- punctaj=0;
- Log_In.conectare();
- }
- if (ev.getSource() == ierarhie) {
- Clasament_actual.createGui();
- }
- if (ev.getSource() == like1) {
- if(semafor_like1==false){
- rating_plus(1);
- semafor_like1=true;
- }
- }
- if (ev.getSource() == dlike1) {
- if(semafor_dlike1==false){
- rating_minus(1);
- semafor_dlike1=true;
- }
- }
- if (ev.getSource() == like2) {
- if(semafor_like2==false){
- rating_plus(2);
- semafor_like2=true;
- }
- }
- if (ev.getSource() == dlike2) {
- if(semafor_dlike2==false){
- rating_minus(2);
- semafor_dlike2=true;
- }
- }
- if (ev.getSource() == like3) {
- if(semafor_like3==false){
- rating_plus(3);
- semafor_like3=true;
- }
- }
- if (ev.getSource() == dlike3) {
- if(semafor_dlike3==false){
- rating_minus(3);
- semafor_dlike3=true;
- }
- }
- if (ev.getSource() == like4) {
- if(semafor_like4==false){
- rating_plus(4);
- semafor_like4=true;
- }
- }
- if (ev.getSource() == dlike4) {
- if(semafor_dlike4==false){
- rating_minus(4);
- semafor_dlike4=true;
- }
- }
- if (ev.getSource() == like5) {
- if(semafor_like5==false){
- rating_plus(5);
- semafor_like5=true;
- }
- }
- if (ev.getSource() == dlike5) {
- if(semafor_dlike5==false){
- rating_minus(5);
- semafor_dlike5=true;
- }
- }
- if (ev.getSource() == like6) {
- if(semafor_like6==false){
- rating_plus(6);
- semafor_like6=true;
- }
- }
- if (ev.getSource() == dlike6) {
- if(semafor_dlike6==false){
- rating_minus(6);
- semafor_dlike6=true;
- }
- }
- if (ev.getSource() == like7) {
- if(semafor_like7==false){
- rating_plus(7);
- semafor_like7=true;
- }
- }
- if (ev.getSource() == dlike7) {
- if(semafor_dlike7==false){
- rating_minus(7);
- semafor_dlike7=true;
- }
- }
- if (ev.getSource() == like8) {
- if(semafor_like8==false){
- rating_plus(8);
- semafor_like8=true;
- }
- }
- if (ev.getSource() == dlike8){
- if(semafor_dlike8==false){
- rating_minus(8);
- semafor_dlike8=true;
- }
- }
- if (ev.getSource() == like9) {
- if(semafor_like9==false){
- rating_plus(9);
- semafor_like9=true;
- }
- }
- if (ev.getSource() == dlike9) {
- if(semafor_dlike9==false){
- rating_minus(9);
- semafor_dlike9=true;
- }
- }
- if (ev.getSource() == like10) {
- if(semafor_like10==false){
- rating_plus(10);
- semafor_like10=true;
- }
- }
- if (ev.getSource() == dlike10) {
- if(semafor_dlike10==false){
- rating_minus(10);
- semafor_dlike10=true;
- }
- }
- }
- public void theQuery2(String query) {
- Connection con = null;
- Statement st = null;
- try {
- con = DriverManager.getConnection("jdbc:mysql://localhost/Aplicatie", "root", "");
- st = con.createStatement();
- st.executeUpdate(query);
- } catch (SQLException | HeadlessException ex) {
- JOptionPane.showMessageDialog(null, ex.getMessage());
- }
- }
- public static void salvare_punctaj(){
- int total = punctaj + punctajbd;
- salvare_punctaj=true;
- try {
- theQuery("update Utilizatori set punctaj= '" + total + "' where id='" + id + "'");
- } catch (Exception ex) {
- }
- }
- public void setCountDownLabelTime(String text) {
- ltimp.setText(text);
- }
- public static void main(String[] args) {
- new Tabela_unica();
- }
- }
- class Timer_tabela {
- private static final int TIMER_PERIOD = 1000;
- protected static final int secunde = 59;
- protected static int minute = 9;
- private Tabela_unica tabela_unica; // holds a reference to the Welcome class
- private int count;
- public Timer_tabela(Tabela_unica tabela_unica) {
- this.tabela_unica = tabela_unica; // initializes the reference to the Welcome class.
- String text = "Timp ramas: "+minute +":"+ (secunde - count) ;
- tabela_unica.setCountDownLabelTime(text);
- }
- public void start() {
- new javax.swing.Timer(TIMER_PERIOD, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if ( Tabela_unica.sfarsit==10) {
- ((javax.swing.Timer) e.getSource()).stop();
- JOptionPane.showMessageDialog(null, "S-a oprit !");
- minute=9;
- } else if (count < secunde && count<=48 && Tabela_unica.sfarsit<10) {
- count++;
- String text ="Timp ramas: " + minute+":"+(secunde - count) ;
- tabela_unica.setCountDownLabelTime(text); // uses the reference to Welcome
- } else if (count < secunde && count>48 && Tabela_unica.sfarsit<10) {
- count++;
- String text ="Timp ramas: " + minute+":0"+(secunde - count) ;
- tabela_unica.setCountDownLabelTime(text); // uses the reference to Welcome
- } else if(count==secunde && minute>0 && Tabela_unica.sfarsit<10){
- count=-1;
- count++;
- minute--;
- String text ="Timp ramas: " +minute+":"+ (secunde - count) ;
- tabela_unica.setCountDownLabelTime(text); // uses the reference to Welcome
- } else if(minute==0 && count==secunde){
- ((javax.swing.Timer) e.getSource()).stop();
- JOptionPane.showMessageDialog(null, "Salut");
- Tabela_unica.salvare_punctaj();
- System.exit(0);
- }
- }
- }).start();
- }
- }
- class ImagePanel2 extends JPanel {
- private Image img1;
- public ImagePanel2(String img1) {
- this(new ImageIcon(img1).getImage());
- }
- public ImagePanel2(Image img1) {
- this.img1 = img1;
- }
- public void paintComponent(Graphics g) {
- g.drawImage(img1, 0, 0, null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement