This commit is contained in:
yann 2021-02-01 01:32:13 +01:00 committed by name
parent fe31c8dfd0
commit 5f5e6292cc

View file

@ -8,7 +8,7 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
/** /**
* Classe permettant de renvoyer les statistiques * Classe permettant de renvoyer les statistiques a partir de la DB
*/ */
public class Statistics { public class Statistics {
public DataBase maDB; public DataBase maDB;
@ -34,39 +34,40 @@ public class Statistics {
/** /**
* Constructeur par defaut : initialise toutes les variables et les tableaux * Constructeur par defaut : initialise toutes les variables et les tableaux
*/ */
public Statistics(){ public Statistics() {
maDB=new DataBase(); maDB = new DataBase();
maDB.getConnection(); maDB.getConnection();
numSelect =new long[5]; numSelect = new long[5];
numId =new long[50][4000]; numId = new long[50][4000];
numCpt = new long[50][2]; numCpt = new long[50][2];
combi1Id =new long[50][4000]; combi1Id = new long[50][4000];
combi1Cpt = new long[50]; combi1Cpt = new long[50];
num1_bonusId =new long[11][4000]; num1_bonusId = new long[11][4000];
num1_bonusCpt = new long[11]; num1_bonusCpt = new long[11];
num2_bonusId =new long[11][4000]; num2_bonusId = new long[11][4000];
num2_bonusCpt = new long[11]; num2_bonusCpt = new long[11];
num3_bonusId =new long[11][4000]; num3_bonusId = new long[11][4000];
num3_bonusCpt = new long[11]; num3_bonusCpt = new long[11];
combi2Id=new long[50][4000]; combi2Id = new long[50][4000];
combi2Cpt=new long[50]; combi2Cpt = new long[50];
bonusId =new long[11][4000]; bonusId = new long[11][4000];
bonusCpt=new long[11][2]; bonusCpt = new long[11][2];
conn= maDB.getConnection(); conn = maDB.getConnection();
} }
/** /**
* Methode renvoyant les numeros avec leur frequence d'apparition * Methode renvoyant les numeros avec leur frequence d'apparition
* @throws SQLException *
* @return affichage numeros * @return affichage numeros
* @throws SQLException
*/ */
public String numero1() throws SQLException { public String numero1() throws SQLException {
System.out.println("debut numero1"); System.out.println("debut numero1");
int k=0, numprec=0, l=0; int k = 0, numprec = 0, l = 0;
ResultSet rs=null; ResultSet rs = null;
String sql; String sql;
int j = 0; int j = 0;
for (int i=1; i<6;i++) { for (int i = 1; i < 6; i++) {
sql = "SELECT Test_Table.boule_" + i + ",Count(*) as 'cnt' FROM myny.Test_Table GROUP BY Test_Table.boule_" + i + "; "; sql = "SELECT Test_Table.boule_" + i + ",Count(*) as 'cnt' FROM myny.Test_Table GROUP BY Test_Table.boule_" + i + "; ";
try { try {
conn = maDB.getConnection(); conn = maDB.getConnection();
@ -91,11 +92,11 @@ public class Statistics {
} }
j++; j++;
} }
j=0; j = 0;
} }
//for (int i=0; i<50;i++) { System.out.println(i+" :"+ numCpt[i][1]); } //for (int i=0; i<50;i++) { System.out.println(i+" :"+ numCpt[i][1]); }
for (int i=1; i<=5;i++) { for (int i = 1; i <= 5; i++) {
sql = "SELECT Test_Table.annee_numero_de_tirage, Test_Table.boule_" + i + " FROM myny.Test_Table ORDER BY Test_Table.boule_" + i + "; "; sql = "SELECT Test_Table.annee_numero_de_tirage, Test_Table.boule_" + i + " FROM myny.Test_Table ORDER BY Test_Table.boule_" + i + "; ";
try { try {
conn = maDB.getConnection(); conn = maDB.getConnection();
@ -114,48 +115,51 @@ public class Statistics {
//rs.next(); //rs.next();
while (rs.next()) { while (rs.next()) {
//System.out.println(numprec+", "+rs.getInt(2)); //System.out.println(numprec+", "+rs.getInt(2));
if(numprec!=rs.getInt(2)) {k = 0;} if (numprec != rs.getInt(2)) {
while(numId[rs.getInt(2)][k]!=0){ k = 0;
}
while (numId[rs.getInt(2)][k] != 0) {
k++; k++;
} }
numId[rs.getInt(2)][k]=rs.getInt(1); numId[rs.getInt(2)][k] = rs.getInt(1);
//System.out.println(numId[rs.getInt(2)][k]); //System.out.println(numId[rs.getInt(2)][k]);
numprec=rs.getInt(2); numprec = rs.getInt(2);
} }
k=0; k = 0;
//j=0; //j=0;
} }
String s = null; String s = null;
for (int i=1; i<50;i++) { for (int i = 1; i < 50; i++) {
s = i+":\n"; s = i + ":\n";
while(numId[i][l]!=0){ while (numId[i][l] != 0) {
s = s +numId[i][l]+", "; s = s + numId[i][l] + ", ";
l++; l++;
} }
l=0; l = 0;
} }
return s; return s;
} }
/** /**
* Methode renvoyant les combinaisons a deux numeros en fonction du premier numero choisi * Methode renvoyant les combinaisons a deux numeros en fonction du premier numero choisi
*
* @param chiffre1 premiere combinaison * @param chiffre1 premiere combinaison
* @throws SQLException
* @return affichage combinaison * @return affichage combinaison
* @throws SQLException
*/ */
public String combinaison2(int chiffre1) throws SQLException { public String combinaison2(int chiffre1) throws SQLException {
numero1(); numero1();
System.out.println("debut combinaison2"); System.out.println("debut combinaison2");
numSelect[1]=chiffre1; numSelect[1] = chiffre1;
int j=0, k=0, l=0, cpt=0; int j = 0, k = 0, l = 0, cpt = 0;
for(int i=1;i<50;i++) { for (int i = 1; i < 50; i++) {
if (i != chiffre1) { if (i != chiffre1) {
while (numId[chiffre1][j] != 0) { while (numId[chiffre1][j] != 0) {
while (numId[i][k] != 0) { while (numId[i][k] != 0) {
//System.out.println(numId[i][k] +"=="+ numId[chiffre1][j]); //System.out.println(numId[i][k] +"=="+ numId[chiffre1][j]);
if (numId[i][k] == numId[chiffre1][j]) { if (numId[i][k] == numId[chiffre1][j]) {
combi1Cpt[i]++; combi1Cpt[i]++;
combi1Id[i][cpt++]=numId[i][k]; combi1Id[i][cpt++] = numId[i][k];
} }
k++; k++;
} }
@ -164,44 +168,45 @@ public class Statistics {
} }
j = 0; j = 0;
} }
cpt=0; cpt = 0;
} }
String s = null; String s = null;
for (int i=1; i<50;i++) { for (int i = 1; i < 50; i++) {
/*for (int p=1; p<50;p++) { /*for (int p=1; p<50;p++) {
System.out.print(combi1Id[i][p]+", "); System.out.print(combi1Id[i][p]+", ");
}*/ }*/
s = i+": "+combi1Cpt[i]+"\n"; s = i + ": " + combi1Cpt[i] + "\n";
while(combi1Id[i][l]!=0){ while (combi1Id[i][l] != 0) {
s = s + combi1Id[i][l]+", "; s = s + combi1Id[i][l] + ", ";
l++; l++;
} }
l=0; l = 0;
} }
return s; return s;
} }
/** /**
* Methode renvoyant les combinaisons a trois numeros en fonction des deux numeros choisi * Methode renvoyant les combinaisons a trois numeros en fonction des deux numeros choisi
*
* @param chiffre1 * @param chiffre1
* @param chiffre2 * @param chiffre2
* @throws SQLException
* @return affichage combinaison * @return affichage combinaison
* @throws SQLException
*/ */
public String combinaison3(int chiffre1, int chiffre2) throws SQLException { public String combinaison3(int chiffre1, int chiffre2) throws SQLException {
numero1(); numero1();
combinaison2(chiffre1); combinaison2(chiffre1);
System.out.println("debut combinaison3"); System.out.println("debut combinaison3");
numSelect[2]=chiffre2; numSelect[2] = chiffre2;
int j=0, k=0, m=0, cpt=0; int j = 0, k = 0, m = 0, cpt = 0;
for(int i=1;i<50;i++) { for (int i = 1; i < 50; i++) {
if (i != chiffre1 && i!=chiffre2) { if (i != chiffre1 && i != chiffre2) {
while (combi1Id[chiffre2][j] != 0){ while (combi1Id[chiffre2][j] != 0) {
while (numId[i][k] != 0) { while (numId[i][k] != 0) {
//System.out.println(numId[i][k] +"=="+ combi1Id[chiffre2][j]); //System.out.println(numId[i][k] +"=="+ combi1Id[chiffre2][j]);
if (numId[i][k] == combi1Id[chiffre2][j]) { if (numId[i][k] == combi1Id[chiffre2][j]) {
combi2Cpt[i]++; combi2Cpt[i]++;
combi2Id[i][cpt++]=numId[i][k]; combi2Id[i][cpt++] = numId[i][k];
} }
k++; k++;
} }
@ -210,33 +215,34 @@ public class Statistics {
} }
j = 0; j = 0;
} }
cpt=0; cpt = 0;
} }
String s = null; String s = null;
for (int i=1; i<50;i++) { for (int i = 1; i < 50; i++) {
/*for (int p=1; p<50;p++) { /*for (int p=1; p<50;p++) {
System.out.print(combi1Id[i][p]+", "); System.out.print(combi1Id[i][p]+", ");
}*/ }*/
s = i+": "+combi2Cpt[i]+"\n"; s = i + ": " + combi2Cpt[i] + "\n";
while(combi2Id[i][k]!=0){ while (combi2Id[i][k] != 0) {
s = s+ combi2Id[i][k]+", "; s = s + combi2Id[i][k] + ", ";
k++; k++;
} }
System.out.println(); System.out.println();
k=0; k = 0;
} }
return s; return s;
} }
/** /**
* Methode renvoyant les numeros bonus avec leur frequence d'apparition * Methode renvoyant les numeros bonus avec leur frequence d'apparition
* @throws SQLException *
* @return affichage numero bonus * @return affichage numero bonus
* @throws SQLException
*/ */
public String bonus() throws SQLException { public String bonus() throws SQLException {
System.out.println("debut bonus"); System.out.println("debut bonus");
int k=0, numprec=0, l=0; int k = 0, numprec = 0, l = 0;
ResultSet rs=null; ResultSet rs = null;
String sql; String sql;
sql = "SELECT Test_Table.numero_chance,Count(*) as 'cnt' FROM myny.Test_Table GROUP BY Test_Table.numero_chance; "; sql = "SELECT Test_Table.numero_chance,Count(*) as 'cnt' FROM myny.Test_Table GROUP BY Test_Table.numero_chance; ";
try { try {
@ -257,8 +263,8 @@ public class Statistics {
bonusCpt[rs.getInt(1)][0] = rs.getInt(1); bonusCpt[rs.getInt(1)][0] = rs.getInt(1);
bonusCpt[rs.getInt(1)][1] = rs.getLong(2); bonusCpt[rs.getInt(1)][1] = rs.getLong(2);
} }
for (int i=0; i<11;i++) { for (int i = 0; i < 11; i++) {
System.out.println(i+" :"+ bonusCpt[i][1]); System.out.println(i + " :" + bonusCpt[i][1]);
} }
sql = "SELECT Test_Table.annee_numero_de_tirage, Test_Table.numero_chance FROM myny.Test_Table ORDER BY Test_Table.numero_chance; "; sql = "SELECT Test_Table.annee_numero_de_tirage, Test_Table.numero_chance FROM myny.Test_Table ORDER BY Test_Table.numero_chance; ";
try { try {
@ -278,167 +284,29 @@ public class Statistics {
//rs.next(); //rs.next();
while (rs.next()) { while (rs.next()) {
//System.out.println(numprec+", "+rs.getInt(2)); //System.out.println(numprec+", "+rs.getInt(2));
if(numprec!=rs.getInt(2)) {k = 0;} if (numprec != rs.getInt(2)) {
while(bonusId[rs.getInt(2)][k]!=0){ k = 0;
}
while (bonusId[rs.getInt(2)][k] != 0) {
k++; k++;
} }
bonusId[rs.getInt(2)][k]=rs.getInt(1); bonusId[rs.getInt(2)][k] = rs.getInt(1);
System.out.println(bonusId[rs.getInt(2)][k]); System.out.println(bonusId[rs.getInt(2)][k]);
numprec=rs.getInt(2); numprec = rs.getInt(2);
} }
k=0; k = 0;
//j=0; //j=0;
String s = null; String s = null;
for (int i=1; i<11;i++) { for (int i = 1; i < 11; i++) {
s = i+":"+bonusCpt[i][1]+"\n"; s = i + ":" + bonusCpt[i][1] + "\n";
while(bonusId[i][l]!=0){ while (bonusId[i][l] != 0) {
s = s + bonusId[i][l]+", "; s = s + bonusId[i][l] + ", ";
l++; l++;
} }
System.out.println(); System.out.println();
l=0; l = 0;
} }
return s; return s;
} }
/**
* Methode renvoyant les numeros bonus en fonction des combinaisons a un numeros
* @param chiffre1
* @throws SQLException
* @return affchage combinaison a un element et numero bonus
*/
public String bonusCombi1(int chiffre1) throws SQLException {
numero1();
this.bonus();
System.out.println("debut bonus");
numSelect[1]=chiffre1;
int j=0, k=0, l=0, cpt=0;
for(int i=1;i<11;i++) {
while (numId[chiffre1][j] != 0) {
while (bonusId[i][k] != 0) {
//System.out.println(bonusId[i][k] +"=="+ numId[chiffre1][j]);
if (bonusId[i][k] == numId[chiffre1][j]) {
num1_bonusCpt[i]++;
num1_bonusId[i][cpt++]=bonusId[i][k];
j++;
}
k++;
}
k = 0;
j++;
}
j = 0;
cpt=0;
}
String s = null;
for (int i=1; i<11;i++) {
/*for (int p=1; p<50;p++) {
System.out.print(combi1Id[i][p]+", ");
}*/
System.out.println(i+": "+num1_bonusCpt[i]);
while(num1_bonusId[i][l]!=0){
System.out.print(num1_bonusId[i][l]+", ");
l++;
}
System.out.println();
l=0;
}
return s;
}
/**
* Methode renvoyant les numeros bonus en fonction des combinaisons a deux numeros
* @param chiffre1
* @param chiffre2
* @throws SQLException
* @return affchage combinaison a deux elements et numero bonus
*/
public String bonusCombi2(int chiffre1, int chiffre2) throws SQLException {
combinaison2(chiffre1);
bonus();
System.out.println("debut bonusCombi2");
numSelect[1]=chiffre1;
numSelect[2]=chiffre2;
int j=0, k=0, l=0, cpt=0;
for(int i=1;i<11;i++) {
while (combi1Id[chiffre2][j] != 0) {
while (bonusId[i][k] != 0) {
//System.out.println(bonusId[i][k] +"=="+ combi1Id[chiffre2][j]);
if (bonusId[i][k] == combi1Id[chiffre2][j]) {
num2_bonusCpt[i]++;
num2_bonusId[i][cpt++]=bonusId[i][k];
j++;
}
k++;
}
k = 0;
j++;
}
j = 0;
cpt=0;
}
String s = null;
for (int i=1; i<11;i++) {
/*for (int p=1; p<50;p++) {
System.out.print(combi1Id[i][p]+", ");
}*/
System.out.println(i+": "+num2_bonusCpt[i]);
while(num2_bonusId[i][l]!=0){
System.out.print(num2_bonusId[i][l]+", ");
l++;
}
System.out.println();
l=0;
}
return s;
}
/**
* Methode renvoyant les numeros bonus en fonction des combinaisons a trois numeros
* @param chiffre1
* @param chiffre2
* @param chiffre3
* @throws SQLException
* @return affchage combinaison a trois elements et numero bonus
*/
public String bonusCombi3(int chiffre1, int chiffre2, int chiffre3) throws SQLException {
combinaison3(chiffre1, chiffre2);
bonus();
System.out.println("debut bonusCombi3");
numSelect[1]=chiffre1;
numSelect[2]=chiffre2;
numSelect[3]=chiffre3;
int j=0, k=0, l=0, cpt=0;
while (combi2Id[chiffre3][j] != 0) {
for(int i=1;i<11;i++) {
while (bonusId[i][k] != 0) {
//System.out.println(combi2Id[chiffre3][j] +"=="+ bonusId[i][k]);
if (bonusId[i][k] == combi2Id[chiffre3][j]) {
num3_bonusCpt[i]++;
num3_bonusId[i][cpt++]=bonusId[i][k];
j++;
}
k++;
}
k = 0;
}
cpt=0;
j++;
}
for (int i=1; i<11;i++) {
/*for (int p=1; p<50;p++) {
System.out.print(combi1Id[i][p]+", ");
}*/
System.out.println(i+": "+num3_bonusCpt[i]);
while(num3_bonusId[i][l]!=0){
System.out.print(num3_bonusId[i][l]+", ");
l++;
}
System.out.println();
l=0;
}
String s = null;
return s;
}
} }