Skip to content

Commit

Permalink
hexagone
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedmezlini committed Nov 12, 2015
0 parents commit f8a9952
Show file tree
Hide file tree
Showing 43 changed files with 3,154 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="C:/Users/mezlini/Desktop/Administration/XbeeProjectWeb/build/web/WEB-INF/lib/mysql-connector-java-5.1.16-bin.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hexagone</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Binary file added bin/bd/DB.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$1.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$10.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$2.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$3.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$4.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$5.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$6.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$7.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$8.class
Binary file not shown.
Binary file added bin/hexagone/Accueil$9.class
Binary file not shown.
Binary file added bin/hexagone/Accueil.class
Binary file not shown.
Binary file added bin/hexagone/AlgoJeu.class
Binary file not shown.
Binary file added bin/hexagone/EtatJeu.class
Binary file not shown.
Binary file added bin/hexagone/Hexagone.class
Binary file not shown.
Binary file added bin/hexagone/Joueur.class
Binary file not shown.
Binary file added bin/hexagone/Logowithname.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/hexagone/Parametre.class
Binary file not shown.
Binary file added bin/hexagone/Plateau.class
Binary file not shown.
Binary file added bin/hexagone/cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/hexagone/iconBleu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/hexagone/iconNoir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/hexagone/iconRouge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/hexagone/iconVert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/hexagone/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
226 changes: 226 additions & 0 deletions src/bd/DB.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
package bd;

import hexagone.Joueur;

import java.io.IOException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JOptionPane;

public class DB {

private static Connection conn;
String url = "jdbc:mysql://localhost:3306/hexagone";

public DB() throws SQLException {
this.conn = DriverManager.getConnection(url, "root", "");
}

public void insert_Joueur(int num, String nom, int score, int perdu,
int actif, int idPartie) {

PreparedStatement ps;
try {
ps = (PreparedStatement) conn
.prepareStatement("INSERT INTO `hexagone`.`joueur` (`id`, `num`, `nom`, `score`, `perdu`, `actif`,`idPartie`) "
+ "VALUES (?, ?, ?, ?, ?, ?,?)");
ps.setString(1, null);
ps.setInt(2, num);
ps.setString(3, nom);
ps.setInt(4, score);
ps.setInt(5, perdu);
ps.setInt(6, actif);
ps.setInt(7, idPartie);

ps.executeUpdate();

} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}
}

public ResultSet getScore() {

Statement statement;
ResultSet resultats = null;
try {
statement = (Statement) conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
resultats = statement
.executeQuery("SELECT * FROM `joueur` ORDER BY `score` DESC Limit 0 , 5");
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}
return resultats;

}

public int getIdPartie() {

int id = 0;

Statement statement;
ResultSet resultats = null;
try {
statement = (Statement) conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
resultats = statement
.executeQuery("SELECT * FROM `partie` ORDER BY `datesave` DESC Limit 0 , 1");
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}

try {
while (resultats.next()) {
id = resultats.getInt(1);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return id;
}


public ResultSet getPartie() {

int id = 0;

Statement statement;
ResultSet resultats = null;
try {
statement = (Statement) conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
resultats = statement
.executeQuery("SELECT * FROM `partie` ORDER BY `datesave` DESC Limit 0 , 1");
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}
return resultats;
}


public ResultSet getJoueurs() {

int id = 0;

Statement statement;
ResultSet resultats = null;
try {
statement = (Statement) conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
resultats = statement
.executeQuery("SELECT * FROM `joueur` where `idPartie`="+this.getIdPartie()
+ "");
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}
return resultats;
}

public ResultSet getHexagons() {

int id = 0;

Statement statement;
ResultSet resultats = null;
try {
statement = (Statement) conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
resultats = statement
.executeQuery("SELECT * FROM `hexagon` where `idPartie`="+this.getIdPartie()
+ "");
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}
return resultats;
}

public void insert_Partie(int longjeu, int nbjoueur, int nbclick,
int ptclickX, int ptclickY, int iteration, int nbhexagone) {

PreparedStatement ps;
try {
ps = (PreparedStatement) conn
.prepareStatement("INSERT INTO `partie`(`id`, `datesave`, `longjeu`, `nbjoueur`, `nbclick`, "
+ "`ptclickX`, `ptclickY`, `iteration`, `nbhexagone`) "
+ "VALUES (?, ?, ?, ?, ?, ?,?,?,?)");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();

ps.setString(1, null);
ps.setString(2, dateFormat.format(cal.getTime()));
ps.setInt(3, longjeu);
ps.setInt(4, nbjoueur);
ps.setInt(5, nbclick);
ps.setInt(6, ptclickX);
ps.setInt(7, ptclickY);
ps.setInt(8, iteration);
ps.setInt(9, nbhexagone);

ps.executeUpdate();

} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}

}

public void insert_Hexagone(int cenrtreX, int centreY, int couleur, int numjoueur,
int radius, int col, int row, int rotation, int sides, int idPartie) {

PreparedStatement ps;
try {
ps = (PreparedStatement) conn
.prepareStatement("INSERT INTO `hexagon`(`id` ,`cenrtreX`, `centreY`,`couleur`, `numjoueur`, "
+ "`radius`, `col`, `row`, `rotation`, `sides`, `idPartie`) "
+ "VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
Date date = new Date(0);

ps.setString(1, null);
ps.setInt(2, cenrtreX);
ps.setInt(3, centreY);
ps.setInt(4, couleur);
ps.setInt(5, numjoueur);
ps.setInt(6, radius);
ps.setInt(7, col);
ps.setInt(8, row);
ps.setInt(9, rotation);
ps.setInt(10, sides);
ps.setInt(11, idPartie);

ps.executeUpdate();

} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}

}




}
Loading

0 comments on commit f8a9952

Please sign in to comment.