Skip to content

Commit fd6151d

Browse files
author
BarbDev
committed
un de plus
1 parent b84706e commit fd6151d

25 files changed

+995
-30
lines changed

src/main/java/bdd/BaseDeDonnee.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
*/
1111
public class BaseDeDonnee {
1212
private Connection bdd;
13-
private HashMap<String, Table> tables = new HashMap<>();
14-
15-
public BaseDeDonnee() {
13+
14+
private static BaseDeDonnee instance = null;
15+
16+
public static BaseDeDonnee getInstance() {
17+
if (instance == null)
18+
instance = new BaseDeDonnee();
19+
return instance;
20+
}
21+
22+
private BaseDeDonnee() {
1623
try {
1724
Class.forName("org.h2.Driver"); // On charge le module H2
1825
/*
@@ -21,8 +28,6 @@ public BaseDeDonnee() {
2128
* TODO : voir le chiffrement de la BDD (simple option normalement)
2229
*/
2330
bdd = DriverManager.getConnection("jdbc:h2:./test", "sa", "");
24-
tables.put("films", new TableFilms(this));
25-
tables.put("utilisateurs", new TableUtilisateurs(this));
2631

2732
} catch (SQLException e) {
2833
e.printStackTrace();
@@ -81,10 +86,8 @@ public void execute(String action) {
8186
}
8287

8388
static public void main(String[] args) {
84-
BaseDeDonnee baseDeDonnee = new BaseDeDonnee();
8589
//baseDeDonnee.ajouter(new Film(1, "Mr Bean", 160, 7.8f, 20, new Date(Date.valueOf("1994-6-10").getTime()),
8690
// "drole", "Mr bean par en vacs :D", new String[]{"Le magnifique", "lul"}));
87-
baseDeDonnee.createTable(null, null);
8891

8992
//for (Film f : baseDeDonnee.getFilms())
9093
// System.out.println(f);

src/main/java/bdd/Table.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public void create(String csvPath) {
3131
//System.out.println("Dans Table::create() ->\n" + stb);
3232
bdd.execute(stb.toString());
3333

34-
34+
if (csvPath != null)
35+
;
3536
}
3637

3738
/**

src/main/java/bdd/TableFilms.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
import java.util.ArrayList;
88

99
public class TableFilms extends Table {
10-
public TableFilms(BaseDeDonnee bdd) {
10+
private static TableFilms instance = null;
11+
12+
public static TableFilms getInstance() {
13+
if (instance == null)
14+
instance = new TableFilms(BaseDeDonnee.getInstance());
15+
return instance;
16+
}
17+
18+
private TableFilms(BaseDeDonnee bdd) {
1119
super(bdd);
1220
}
1321

src/main/java/bdd/TableUtilisateurs.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66
import java.sql.SQLException;
77

88
public class TableUtilisateurs extends Table {
9+
private static TableUtilisateurs instance = null;
910

10-
public TableUtilisateurs(BaseDeDonnee bdd) {
11+
public static TableUtilisateurs getInstance() {
12+
if (instance == null)
13+
instance = new TableUtilisateurs(BaseDeDonnee.getInstance());
14+
return instance;
15+
}
16+
17+
private TableUtilisateurs(BaseDeDonnee bdd) {
1118
super(bdd);
1219
}
1320

src/main/java/core/MoteurDeRecherche.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import bdd.BaseDeDonnee;
44
import bdd.Film;
5+
import bdd.TableFilms;
6+
import bdd.TableUtilisateurs;
57
import core.Criteres.Critere;
8+
import ihm.main.Principale;
69

710
import java.util.ArrayList;
811
import java.util.Collections;
@@ -28,10 +31,7 @@ public MoteurDeRecherche(BaseDeDonnee bdd) {
2831
}
2932

3033
/**
31-
* Va simplement mettre à jour la liste des résultats.
32-
* TODO : je ne sais pas si c'est utile de la renvoyer aussi (évite de passer par un getResultats())
33-
*
34-
* C'est encore un peu le bordel, je sais pas trop comment lier les critères aux caractèristiques d'un film.
34+
* Met à jour la liste des résultats et la renvoie.
3535
*
3636
* Cette fonction va instancier des résultats dans sa list resultats.
3737
* Pour cela il va calculer les scores un à un.
@@ -52,4 +52,16 @@ public ArrayList<Resultat> rechercher(Critere... criteres) {
5252
Collections.sort(resultats, Collections.reverseOrder());
5353
return resultats;
5454
}
55+
56+
public static void main(String[] args) {
57+
BaseDeDonnee bdd = BaseDeDonnee.getInstance();
58+
TableFilms tf = TableFilms.getInstance();
59+
TableUtilisateurs tu = TableUtilisateurs.getInstance();
60+
61+
bdd.createTable(tf, null);
62+
bdd.createTable(tu, null);
63+
64+
Principale fenPrincipale = new Principale("Comparateur Film");
65+
fenPrincipale.setVisible(true);
66+
}
5567
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package Fait;
2+
3+
import java.awt.FlowLayout;
4+
import java.awt.GridBagConstraints;
5+
import java.awt.GridBagLayout;
6+
import java.awt.Insets;
7+
8+
import javax.swing.JButton;
9+
import javax.swing.JFrame;
10+
import javax.swing.JLabel;
11+
import javax.swing.JPanel;
12+
import javax.swing.JPasswordField;
13+
import javax.swing.JTextField;
14+
15+
public class ChangerMdp {
16+
17+
public static void main(String[] args) {
18+
JFrame fen = new JFrame();
19+
fen.setSize(500, 250);
20+
fen.setTitle("Modification du mot de passe");
21+
fen.setLocationRelativeTo(null);
22+
fen.setLayout(new FlowLayout());
23+
24+
JPanel centre = new JPanel();
25+
centre.setLayout(new GridBagLayout());
26+
27+
GridBagConstraints gbc = new GridBagConstraints();
28+
gbc.gridx = 0;
29+
gbc.gridy = 0;
30+
31+
JLabel mdpactuel = new JLabel("Ancien Mot de Passe: ", JLabel.CENTER);
32+
JLabel nvmdpl = new JLabel("Nouveau mot de passe: ", JLabel.CENTER);
33+
JLabel confmdpl = new JLabel("Confirmer nouveau mot de passe: ", JLabel.CENTER);
34+
35+
JPasswordField mdpactu = new JPasswordField(10);
36+
JPasswordField nvmdp = new JPasswordField(10);
37+
JPasswordField confmdp = new JPasswordField(10);
38+
39+
40+
mdpactuel.setLabelFor(mdpactu);
41+
nvmdpl.setLabelFor(nvmdp);
42+
confmdpl.setLabelFor(confmdp);
43+
44+
gbc.insets = new Insets(10, 5, 7, 1);
45+
centre.add(mdpactuel, gbc);
46+
gbc.gridy++;
47+
centre.add(nvmdpl, gbc);
48+
gbc.gridy++;
49+
centre.add(confmdpl, gbc);
50+
gbc.gridy++;
51+
52+
gbc.gridx++;
53+
gbc.gridy = 0;
54+
centre.add(mdpactu, gbc);
55+
gbc.gridy++;
56+
centre.add(nvmdp, gbc);
57+
gbc.gridy++;
58+
centre.add(confmdp, gbc);
59+
gbc.gridy++;
60+
61+
gbc.gridy++;
62+
centre.add(new JButton("Valider"),gbc);
63+
gbc.gridx++;
64+
centre.add(new JButton("Annuler"),gbc);
65+
gbc.gridy++;
66+
67+
fen.setContentPane(centre);
68+
fen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
69+
fen.setVisible(true);
70+
71+
}
72+
}

src/main/java/ihm/Fait/Connexion.java

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package Fait;
2+
3+
import java.awt.FlowLayout;
4+
import java.awt.Font;
5+
import java.awt.GridBagConstraints;
6+
import java.awt.GridBagLayout;
7+
import java.awt.Insets;
8+
9+
import javax.swing.JButton;
10+
import javax.swing.JFrame;
11+
import javax.swing.JLabel;
12+
import javax.swing.JPanel;
13+
import javax.swing.JPasswordField;
14+
import javax.swing.JSeparator;
15+
import javax.swing.JTextField;
16+
17+
public class Connexion {
18+
public static void main(String[] args) {
19+
//TODO tracer trait
20+
JFrame fen = new JFrame();
21+
fen.setSize(500, 300);
22+
fen.setTitle("Login");
23+
fen.setLocationRelativeTo(null);
24+
fen.setLayout(new FlowLayout());
25+
26+
JPanel centre = new JPanel();
27+
centre.setLayout(new GridBagLayout());
28+
29+
30+
GridBagConstraints gbc = new GridBagConstraints();
31+
gbc.gridx = 0;
32+
gbc.gridy = 0;
33+
34+
JLabel mess = new JLabel("Veuillez vous identifier. ");
35+
mess.setFont(new Font("Serif", Font.BOLD, 20));
36+
JLabel pseudol = new JLabel("Identifiant: ");
37+
JLabel mdpl = new JLabel("Mot de Passe: ");
38+
39+
JTextField pseudo = new JTextField(10);
40+
JPasswordField mdp = new JPasswordField(10);
41+
42+
pseudol.setLabelFor(pseudo);
43+
mdpl.setLabelFor(mdp);
44+
45+
gbc.gridy = 0;
46+
gbc.gridx = 1;
47+
gbc.anchor = GridBagConstraints.CENTER;
48+
gbc.insets = new Insets(10, 5, 10, 1);
49+
centre.add(mess,gbc);
50+
51+
gbc.insets = new Insets(5, 5, 5, 1);
52+
gbc.gridy = 1;
53+
gbc.gridx = 0;
54+
centre.add(pseudol, gbc);
55+
gbc.gridy = 2;
56+
centre.add(mdpl, gbc);
57+
gbc.gridy = 3;
58+
59+
gbc.gridx = 1;
60+
gbc.gridy = 1;
61+
centre.add(pseudo, gbc);
62+
gbc.gridy = 2;
63+
centre.add(mdp, gbc);
64+
65+
gbc.gridy=4;
66+
centre.add(new JButton("Valider"),gbc);
67+
gbc.gridx = 2;
68+
centre.add(new JButton("Annuler"),gbc);
69+
70+
71+
// JSeparator separator = new JSeparator();
72+
// gbc.gridx = 0;
73+
// gbc.anchor = GridBagConstraints.CENTER;
74+
// gbc.fill = GridBagConstraints.HORIZONTAL;
75+
// gbc.insets = new Insets(3, 5, 0, 5);
76+
// centre.add(separator, gbc);
77+
// gbc.gridy++;
78+
79+
gbc.gridy= 5;
80+
gbc.insets = new Insets(10, 5, 5, 1);
81+
gbc.gridx=0;
82+
centre.add(new JLabel("Pas encore inscrit ? --->"),gbc);
83+
gbc.gridx=1;
84+
centre.add(new JButton("Inscris-toi"),gbc);
85+
86+
fen.setContentPane(centre);
87+
fen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
88+
fen.setVisible(true);
89+
}
90+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ihm.Fait;
2+
3+
import java.awt.FlowLayout;
4+
5+
import javax.swing.JButton;
6+
import javax.swing.JFrame;
7+
import javax.swing.JPanel;
8+
9+
public class ContinuerAchat {
10+
11+
12+
public static void main(String[] args) {
13+
14+
JFrame fen = new JFrame();
15+
JPanel panel = new JPanel();
16+
panel.setLayout(new FlowLayout());
17+
18+
JButton bouton = new JButton("Payez");
19+
panel.add(bouton);
20+
21+
JButton bouton2 = new JButton("Continuer");
22+
panel.add(bouton2);
23+
24+
fen.setContentPane(panel);
25+
fen.setVisible(true);
26+
fen.setSize(400, 100);
27+
fen.setTitle("Continuer achat ou payer");
28+
fen.setLocationRelativeTo(null);
29+
fen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
30+
}
31+
}

0 commit comments

Comments
 (0)