Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void versenyez(String kocsivalaszt, String kategoria, int tet)
- throws SQLException {
- JOptionPane jop = new JOptionPane();
- String jatekosquery = "SELECT kocsi_neve, loero, suly, vegsebesseg, gyorsulas FROM kocsi WHERE kocsi_neve = '"
- + kocsivalaszt + "'";
- String ellenfelquery = "SELECT kocsi_neve, loero, suly, vegsebesseg, gyorsulas FROM kocsi ORDER BY rand() LIMIT 1";
- try {
- Class.forName(driver);
- Connection conn = DriverManager.getConnection(url + dbName,
- userName, password);
- Statement st = conn.createStatement();
- ResultSet jatekosRs = st.executeQuery(jatekosquery);
- ResultSet ellenfelRs = st.executeQuery(ellenfelquery);
- String ellenfelKocsi = "";
- int ellenfelLoero = 0;
- int ellenfelSuly = 0;
- int ellenfelVegsebesseg = 0;
- int ellenfelGyorsulas = 0;
- String jatekosKocsi = "";
- int jatekosLoero = 0;
- int jatekosSuly = 0;
- int jatekosVegsebesseg = 0;
- int jatekosGyorsulas = 0;
- while (ellenfelRs.next()) {
- ellenfelKocsi = ellenfelRs.getString("kocsi_neve");
- ellenfelLoero = ellenfelRs.getInt("loero");
- ellenfelSuly = ellenfelRs.getInt("suly");
- ellenfelVegsebesseg = ellenfelRs.getInt("vegsebesseg");
- ellenfelGyorsulas = ellenfelRs.getInt("gyorsulas");
- }
- while (jatekosRs.next()) {
- jatekosKocsi = jatekosRs.getString("kocsi_neve");
- jatekosLoero = jatekosRs.getInt("loero");
- jatekosSuly = jatekosRs.getInt("suly");
- jatekosVegsebesseg = jatekosRs.getInt("vegsebesseg");
- jatekosGyorsulas = jatekosRs.getInt("gyorsulas");
- }
- // vizsgalo resz
- if (kategoria.equals("loero")) {
- if (jatekosLoero > ellenfelLoero) {
- JOptionPane.showMessageDialog(jop, "Gratulalok, nyertel"
- + tet + " Ft-ot loero kategoriaban!");
- penz += tet;
- MainGUI.penzStatusLabel.setText("Penz: " + penz + " Ft");
- } else if (jatekosLoero < ellenfelLoero) {
- JOptionPane.showMessageDialog(jop, "Vesztettel :( " + tet
- + " Ft-ot!, "+ellenfelKocsi+" nyert!");
- penz -= tet;
- MainGUI.penzStatusLabel.setText("Penz: " + penz + " Ft");
- } else {
- JOptionPane.showMessageDialog(jop,
- "Dontetlen lett az eredmeny");
- }
- }
- else if (kategoria.equals("suly")) {
- if (jatekosSuly > ellenfelSuly) {
- JOptionPane.showMessageDialog(jop, "Gratulalok, nyertel"
- + tet + " Ft-ot suly!");
- penz += tet;
- MainGUI.penzStatusLabel.setText("Penz: " + penz + " Ft");
- } else if (jatekosSuly < ellenfelSuly) {
- JOptionPane.showMessageDialog(jop, "Vesztettel :( " + tet
- + " Ft-ot!, "+ellenfelKocsi+" nyert!");
- penz -= tet;
- MainGUI.penzStatusLabel.setText("Penz: " + penz + " Ft");
- } else {
- JOptionPane.showMessageDialog(jop,
- "Dontetlen lett az eredmeny");
- }
- }
- else if (kategoria.equals("vegsebesseg")) {
- if (jatekosVegsebesseg > ellenfelVegsebesseg) {
- JOptionPane.showMessageDialog(jop, "Gratulalok, nyertel"
- + tet + " Ft-ot vegsebesseg kategoriaban!");
- penz += tet;
- MainGUI.penzStatusLabel.setText("Penz: " + penz + " Ft");
- } else if (jatekosVegsebesseg < ellenfelVegsebesseg) {
- JOptionPane.showMessageDialog(jop, "Vesztettel :( " + tet
- + " Ft-ot!, "+ellenfelKocsi+" nyert!");
- penz -= tet;
- MainGUI.penzStatusLabel.setText("Penz: " + penz + " Ft");
- } else {
- JOptionPane.showMessageDialog(jop,
- "Dontetlen lett az eredmeny");
- }
- }
- else if (kategoria.equals("gyorsulas")) {
- if (jatekosGyorsulas > ellenfelGyorsulas) {
- JOptionPane.showMessageDialog(jop, "Gratulalok, nyertel"
- + tet + " Ft-ot gyorsulas kategoriaban!");
- penz += tet;
- MainGUI.penzStatusLabel.setText("Penz: " + penz + " Ft");
- } else if (jatekosGyorsulas < ellenfelGyorsulas) {
- JOptionPane.showMessageDialog(jop, "Vesztettel :( " + tet
- + " Ft-ot!, "+ellenfelKocsi+" nyert!");
- penz -= tet;
- MainGUI.penzStatusLabel.setText("Penz: " + penz + " Ft");
- } else {
- JOptionPane.showMessageDialog(jop,
- "Dontetlen lett az eredmeny");
- }
- }
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement