From 831ee605270cc30a4939213d5a59b1c133360ca9 Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 18 Sep 2024 13:48:20 +0200 Subject: [PATCH 1/8] Connexion sql + panel questions --- src/main/resources/db.properties | 5 +++ src/main/resources/db.sql | 69 ++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/main/resources/db.properties create mode 100644 src/main/resources/db.sql diff --git a/src/main/resources/db.properties b/src/main/resources/db.properties new file mode 100644 index 0000000..985af6a --- /dev/null +++ b/src/main/resources/db.properties @@ -0,0 +1,5 @@ +server=wp.ldnr.fr +port=3306 +dbname=cda202401_jse_g5 +user=cda202401_jse_g5 +password=n3z3XS9y9z8jZOnB diff --git a/src/main/resources/db.sql b/src/main/resources/db.sql new file mode 100644 index 0000000..904bb6e --- /dev/null +++ b/src/main/resources/db.sql @@ -0,0 +1,69 @@ +-- phpMyAdmin SQL Dump +-- version 4.9.6 +-- https://www.phpmyadmin.net/ +-- +-- Hôte : localhost +-- Généré le : mer. 18 sep. 2024 à 10:40 +-- Version du serveur : 10.1.48-MariaDB-0+deb9u2 +-- Version de PHP : 7.4.33 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Base de données : `cda202401_jse_g5` +-- + +-- -------------------------------------------------------- + +-- +-- Structure de la table `questions` +-- + +CREATE TABLE `questions` ( + `id` int(11) NOT NULL, + `number` int(11) NOT NULL, + `level` int(11) NOT NULL, + `statement` text NOT NULL, + `answer` text NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- +-- Déchargement des données de la table `questions` +-- + +INSERT INTO `questions` (`id`, `number`, `level`, `statement`, `answer`) VALUES +(1, 1, 1, 'Comment ça va?', 'bieng'); + +-- +-- Index pour les tables déchargées +-- + +-- +-- Index pour la table `questions` +-- +ALTER TABLE `questions` + ADD PRIMARY KEY (`id`); + +-- +-- AUTO_INCREMENT pour les tables déchargées +-- + +-- +-- AUTO_INCREMENT pour la table `questions` +-- +ALTER TABLE `questions` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -- GitLab From b74d2d13bdc218e67d126d1d26231240f1cb2bf3 Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 18 Sep 2024 16:04:28 +0200 Subject: [PATCH 2/8] DAO questions + tests(bugged) --- pom.xml | 14 +++ src/main/java/beans/Question.java | 77 ++++++++++++ .../com/mycompany/groupe_05/Groupe_05.java | 11 +- .../com/mycompany/groupe_05/TestFrame.java | 32 +++++ src/main/java/dao/Dao.java | 47 ++++++++ src/main/java/dao/DaoQuestion.java | 111 ++++++++++++++++++ src/main/java/gui/QuestionsGui.java | 70 +++++++++++ src/main/java/sql/MariaDbConnection.java | 77 ++++++++++++ src/test/java/dao/DaoQuestionTest.java | 56 +++++++++ target/classes/beans/Drawing$DrawArea$1.class | Bin 1167 -> 1167 bytes target/classes/beans/Drawing$DrawArea$2.class | Bin 1530 -> 1530 bytes target/classes/beans/Drawing$DrawArea.class | Bin 2273 -> 2406 bytes target/classes/beans/Drawing.class | Bin 5102 -> 3647 bytes .../com/mycompany/groupe_05/Groupe_05.class | Bin 489 -> 810 bytes .../compile/default-compile/createdFiles.lst | 11 +- .../compile/default-compile/inputFiles.lst | 10 +- 16 files changed, 511 insertions(+), 5 deletions(-) create mode 100644 src/main/java/beans/Question.java create mode 100644 src/main/java/com/mycompany/groupe_05/TestFrame.java create mode 100644 src/main/java/dao/Dao.java create mode 100644 src/main/java/dao/DaoQuestion.java create mode 100644 src/main/java/gui/QuestionsGui.java create mode 100644 src/main/java/sql/MariaDbConnection.java create mode 100644 src/test/java/dao/DaoQuestionTest.java diff --git a/pom.xml b/pom.xml index 5cdb5d4..ffdd7d6 100644 --- a/pom.xml +++ b/pom.xml @@ -5,6 +5,20 @@ Groupe_05 1.0-SNAPSHOT jar + + + org.mariadb.jdbc + mariadb-java-client + 3.4.1 + + + org.junit.jupiter + junit-jupiter-api + 5.10.2 + test + jar + + UTF-8 17 diff --git a/src/main/java/beans/Question.java b/src/main/java/beans/Question.java new file mode 100644 index 0000000..2d5f01b --- /dev/null +++ b/src/main/java/beans/Question.java @@ -0,0 +1,77 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package beans; + +/** + * + * @author Clément GROSSELLE + */ +public class Question { + private int id; + private int number; + private int level; + private String statement; + private String answer; + + public Question() { + } + + public int getNumber() { + return number; + } + + public void setNumber(int number) { + this.number = number; + } + + public void setId(int id) { + this.id = id; + } + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public String getStatement() { + return statement; + } + + public void setStatement(String statement) { + this.statement = statement; + } + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + public int getId() { + return id; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Questions{"); + sb.append("id=").append(id); + sb.append(", number=").append(number); + sb.append(", level=").append(level); + sb.append(", statement=").append(statement); + sb.append(", answer=").append(answer); + sb.append('}'); + return sb.toString(); + } + + + + +} diff --git a/src/main/java/com/mycompany/groupe_05/Groupe_05.java b/src/main/java/com/mycompany/groupe_05/Groupe_05.java index 585e8f5..1efa59c 100644 --- a/src/main/java/com/mycompany/groupe_05/Groupe_05.java +++ b/src/main/java/com/mycompany/groupe_05/Groupe_05.java @@ -1,10 +1,17 @@ package com.mycompany.groupe_05; -import beans.Drawing; +import beans.Question; +import dao.DaoQuestion; public class Groupe_05 { public static void main(String[] args) { - Drawing Draw = new Drawing(); + new TestFrame(); + Question q = new Question(); + DaoQuestion daoq = new DaoQuestion(); + q = daoq.find(1); + System.out.println(q); + } + } diff --git a/src/main/java/com/mycompany/groupe_05/TestFrame.java b/src/main/java/com/mycompany/groupe_05/TestFrame.java new file mode 100644 index 0000000..fd559ce --- /dev/null +++ b/src/main/java/com/mycompany/groupe_05/TestFrame.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.mycompany.groupe_05; + +import gui.QuestionsGui; +import javax.swing.JFrame; +import javax.swing.JPanel; + +/** + * + * @author stag + */ +public class TestFrame extends JFrame { + JPanel qPane = new QuestionsGui(); + + public TestFrame() { + this.initGui(); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setResizable(true); + this.pack(); + //this.setSize(300, 500); + this.setLocationRelativeTo(null); + this.setVisible(true); + } + + private void initGui() { + this.add(qPane); + this.setContentPane(qPane); + } +} diff --git a/src/main/java/dao/Dao.java b/src/main/java/dao/Dao.java new file mode 100644 index 0000000..1d95ae5 --- /dev/null +++ b/src/main/java/dao/Dao.java @@ -0,0 +1,47 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package dao; + +import java.util.Collection; + +/** + * Interface CRUD sur le stockage des données + * @author Clément GROSSELLE + * @param La classe + */ +public interface Dao { + + /** + * Retourne l'objet lu en DB grâce à son identifiant ou null. + * @param id L'identifiant en DB de l'objet + * @return L'objet ou null + */ + T find(int id); + + /** + * Hydrate la DB avec l'objet fourni. Cet objet doit avoir un id null. + * @param obj + */ + void create(T obj); + + /** + * Supprime la ligne d'identifiant id dans la DB. + * @param id + */ + void delete(int id); + + /** + * Met à jour l'objet dans la DB. L'objet doit avoir un id non null. + * @param obj + */ + void update(T obj); + + /** + * Retourne toutes les lignes de la DB dans une collection. + * @return Collection contenant tous les objets hydratés par la DB. + */ + Collection all(); + +} diff --git a/src/main/java/dao/DaoQuestion.java b/src/main/java/dao/DaoQuestion.java new file mode 100644 index 0000000..608ed64 --- /dev/null +++ b/src/main/java/dao/DaoQuestion.java @@ -0,0 +1,111 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package dao; + +import beans.Question; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import sql.MariaDbConnection; + +/** + * + * @author Clément GROSSELLE + */ +public class DaoQuestion implements Dao { + + private final Connection connect = MariaDbConnection.getInstance(); + + private Question createBean(ResultSet rs) { + Question obj = new Question(); + try { + obj.setNumber(rs.getInt("number")); + obj.setLevel(rs.getInt("level")); + obj.setStatement(rs.getString("statement")); + obj.setAnswer(rs.getString("answer")); + } catch (SQLException ex) { + System.out.println("Impossible de parcourir le resultSet"); + } + return obj; + } + + @Override + public Question find(int id) { + Question q = null; + String sql = "SELECT * FROM questions WHERE id=?"; + try (PreparedStatement pstmt = connect.prepareStatement(sql)) { + pstmt.setInt(1, id); + ResultSet rs = pstmt.executeQuery(sql); + if (rs.next()) { + q = createBean(rs); + } + } catch (SQLException ex) { + throw new RuntimeException("Recherche impossible dans la table questions"); + } + return q; + } + + @Override + public void create(Question obj) { + String sql = "INSERT INTO questions (level, statement, answer) VALUES (?, ?, ?)"; + try (PreparedStatement pstmt = connect.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS)) { + pstmt.setInt(1, obj.getLevel()); + pstmt.setString(2, obj.getStatement()); + pstmt.setString(3, obj.getAnswer()); + pstmt.executeUpdate(); + ResultSet keys = pstmt.getGeneratedKeys(); + if (keys.next()) { + obj.setId(keys.getInt(1)); + } + } catch (SQLException ex) { + throw new RuntimeException("Insertion impossible dans la table questions"); + } + } + + @Override + public void delete(int id) { + String sql = "DELETE FROM questions WHERE id=?"; + try (PreparedStatement pstmt = connect.prepareStatement(sql)) { + pstmt.setInt(1, id); + pstmt.executeUpdate(); + } catch (SQLException ex) { + throw new RuntimeException("Suppression impossible dans la table questions"); + } + } + + @Override + public void update(Question obj) { + String sql = "UPDATE questions SET number=?, level=?, statement=?, answer=? WHERE id=?"; + try (PreparedStatement pstmt = connect.prepareStatement(sql)) { + pstmt.setInt(1, obj.getNumber()); + pstmt.setInt(2, obj.getLevel()); + pstmt.setString(3, obj.getStatement()); + pstmt.setString(4, obj.getAnswer()); + pstmt.setInt(4, obj.getId()); + pstmt.executeUpdate(); + } catch (SQLException ex) { + throw new RuntimeException("Update impossible dans la table questions"); + } + } + + @Override + public Collection all() { + Collection list = new ArrayList<>(); + String sql = "SELECT * FROM questions"; + try (PreparedStatement pstmt = connect.prepareStatement(sql)) { + ResultSet rs =pstmt.executeQuery(); + while (rs.next()) { + list.add(createBean(rs)); + } + } catch (SQLException ex) { + System.out.println("Récupération impossible de la table questions"); + } + return list; + } + +} diff --git a/src/main/java/gui/QuestionsGui.java b/src/main/java/gui/QuestionsGui.java new file mode 100644 index 0000000..42158d2 --- /dev/null +++ b/src/main/java/gui/QuestionsGui.java @@ -0,0 +1,70 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package gui; + +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/** + * + * @author CLément GROSSELLE + */ +public class QuestionsGui extends JPanel { + JPanel questionsPane, statmentPane, answerPane, buttonsPane; + JLabel sLabel, aLabel; + JTextField atf; + JButton confirmButton, showButton, nextButton; + + public QuestionsGui() { + questionsPane = new JPanel(); + statmentPane = new JPanel(); + answerPane = new JPanel(); + buttonsPane = new JPanel(); + confirmButton = new JButton("Valider réponse"); + showButton = new JButton("Afficher réponse"); + nextButton = new JButton("Question suivante"); + sLabel = new JLabel("Ici la question"); + aLabel = new JLabel("Saisissez votre réponse"); + atf = new JTextField(30); + initGui(); + initEvent(); + } + + private void initGui() { + this.setBorder(BorderFactory.createLineBorder(Color.red)); + questionsPane.setLayout(new BoxLayout(questionsPane, BoxLayout.Y_AXIS)); + answerPane.setLayout(new BoxLayout(answerPane, BoxLayout.Y_AXIS)); + statmentPane.setBorder(BorderFactory.createLineBorder(Color.yellow)); + answerPane.setBorder(BorderFactory.createLineBorder(Color.green)); + buttonsPane.setBorder(BorderFactory.createLineBorder(Color.blue)); + statmentPane.add(sLabel); + answerPane.add(aLabel); + answerPane.add(atf); + buttonsPane.add(confirmButton); + buttonsPane.add(showButton); + buttonsPane.add(nextButton); + questionsPane.add(statmentPane); + questionsPane.add(answerPane); + questionsPane.add(buttonsPane); + this.add(questionsPane); + + } + + private void initEvent() { + confirmButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ae) { + System.out.println("bouton validé"); + } + }); + } +} diff --git a/src/main/java/sql/MariaDbConnection.java b/src/main/java/sql/MariaDbConnection.java new file mode 100644 index 0000000..736e7f2 --- /dev/null +++ b/src/main/java/sql/MariaDbConnection.java @@ -0,0 +1,77 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package sql; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author Clément GROSSELLE + */ +public class MariaDbConnection { + + private static Connection instance; + + public MariaDbConnection() { + } + + public static Connection getInstance() throws RuntimeException { + if (instance == null) { + Properties config = getConfig(); + try { + Class.forName("org.mariadb.jdbc.Driver"); + } catch (ClassNotFoundException ex) { + throw new RuntimeException("Driver introuvable"); + } + String server = config.getProperty("server"); + String port = config.getProperty("port"); + String dbname = config.getProperty("dbname"); + String url = "jdbc:mariadb://" + server + ":" + port + "/" + dbname; + try { + instance = DriverManager.getConnection(url, config); + } catch (SQLException ex) { + throw new RuntimeException("Connection à la base de donnée impossible\t Message:" + ex.getMessage()); + } + } + return instance; + } + + private static Properties getConfig() { + Properties config = new Properties(); + try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("db.properties")) { + config.load(is); + } catch (FileNotFoundException ex) { + throw new RuntimeException("Fichier de paramétrage inexistant"); + } catch (IOException ex) { + throw new RuntimeException("Fichier de paramétrage illisible"); + } + return config; + } + + public static void closeConnection() { + if (instance != null) { + try { + instance.close(); + } catch (SQLException ex) { + Logger.getLogger(MariaDbConnection.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + public static void main(String[] args) { + getInstance(); + closeConnection(); + + } + +} diff --git a/src/test/java/dao/DaoQuestionTest.java b/src/test/java/dao/DaoQuestionTest.java new file mode 100644 index 0000000..4747cb5 --- /dev/null +++ b/src/test/java/dao/DaoQuestionTest.java @@ -0,0 +1,56 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package dao; + +import beans.Question; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +/** + * + * @author CLément GROSSELLE + */ +public class DaoQuestionTest { + + public DaoQuestionTest() { + } + + @Test + public void testAllCrudMethods() { + DaoQuestion daoq = new DaoQuestion(); + Question q = new Question(); + + System.out.println("Test de la méthode find"); + assertDoesNotThrow(() -> daoq.find(1)); + assertNotNull(daoq.find(1)); + assertNull(daoq.find(0)); + + System.out.println("Test de la méthode create"); + q.setStatement("test"); + q.setLevel(100); + assertDoesNotThrow(() -> daoq.create(q)); + assertNotNull(q.getId()); + + System.out.println("Test de la méthode update"); + q.setStatement("pouet"); + q.setLevel(50); + assertDoesNotThrow(() -> daoq.update(q)); + assertEquals("pouet", daoq.find(q.getId()).getStatement()); + assertEquals("50", daoq.find(q.getId()).getLevel()); + + System.out.println("Test de la méthode delete"); + assertDoesNotThrow(() -> daoq.delete(q.getId())); + assertNull(daoq.find(q.getId())); + } + + @Test + public void testAll() { + DaoQuestion daoq =new DaoQuestion(); + System.out.println("Test de la méthode all"); + assertDoesNotThrow(() -> daoq.all()); + assertEquals(daoq.all().size(), 1); + } + +} diff --git a/target/classes/beans/Drawing$DrawArea$1.class b/target/classes/beans/Drawing$DrawArea$1.class index aab4a789bc4bb9af8738a9261368f6a92a95c755..8010ec4c6b24722ecab7f797fdc34d6c9bd03767 100644 GIT binary patch delta 35 qcmeC@?C0FDoS89V@(Si!!Dt3mXr?i+GNdzbF=R4`Gh{KSGvqK>GZZjHG88ftGZZsaF_bVg PF_bcNF_ca2U@Zaw-^C99 delta 59 zcmeyx{fm3UBo@Y^$&*>mXqGatGL$iJF;p;!GgLCDGgLEJGt@CeGSo8^Gc+(%F*GtX PF*GrBF*Hx^U@Zaw@>vh5 diff --git a/target/classes/beans/Drawing$DrawArea.class b/target/classes/beans/Drawing$DrawArea.class index bc680f548466c89767dc8482fb959d77c57556a6..5e2bf9fe2cd9e743b7059600e9060f33ca01913d 100644 GIT binary patch delta 1045 zcmaDT_)LiF)W2Q(7#J9A876Mzn#;(>&Y;A|ATjZrSd@w}7lR^$2p0nrgDMY$8iP6` zgGgdZigSK$L4ICpUWrd;aY<@kY7rxYs)kQiVp*boVtI*vYFTPti9UuRYt1l_L7F@a zS`6BgH!^Cn>GCk>G3ZZzz$nXY$Y8|IV9di{!eBa?gUQmzoRL8oZlHTnVnIe`a1!w|#}Jb5v*GKU#MC=Wvz zL-^!#%;Hks43RtxQ4Ic!46IH*j?Ug(3}y^5JPff6ag+ZutFk5VFeEZ0P1a&jk8Tte?V=#lw)zkip2nmXVs7o>2k{iCi9rJO&;{2KJ)Vg2c?c5-tV~ zh5{ajLWZKrYglx+OBhPo8OnGV${8v)KW4FEWbB@-z^234KiQYf&{mH@pMima2^11w zx{@ISOjm(u0RaY91~vu;1{MZJ25yFG21bS&1_p)_237_p1_lPR$-CJ!>a}(=C`M{& zZ)Z^6#-Oqhthttffk6taF@%AWA(VlSA%a1gA(=sgp^Cwjp@*T4fq{XCfe~Z`Lp?(S zSWhEE6V&+G46F>y3=9meT3XUF+ZZ&qGU#Y&ZDG*a#$a%O!E7soh1M1Zi%kqRn;4w7 zF}T%3cwXBW0zfQgW{{o`5OWhl#5RTigp1@D*cliYCNOX@Ok|K?n8cvUFquK0VG4s4 z!&C+rhG}3|DL`z7x{86p6%_Jdm%4(2oq>sgk)avvc2GcMF|ab!gS=q?vCnH8Lo|rR z%&fJIA$|)(GK9+9#(;28wAMC;9E7997+4t?7-lhWG0bLAWSGOC%`lfipJ5)@F_0iK zfI5Z+6rs={N`l6Kq?UI5c7}XV=p19<*9Otd%#7O@io-!RFf)K6LWqHdfq`KW11rN~ z1|Ehb3=#~>z^03V<4_W6Is=0wLkmMI10zEl0|Nsy1ET~3GebK#W;z%;!E_fx4+8^( k7TD@8hF%6H20;b}25AOxWP?Zs21N+P(8plQFoA^=0K7HAoB#j- delta 900 zcmaDR^iYuN)W2Q(7#J9A8M-!d&1K}`VqjuW;$cu`P?;>tq{*hn!=TQfG1-SnmRpNK zo1H<2he4M?Z*mEfC8NRQbxcxhMm!A03?`G$F)47HF_^P6Snx1dGFVOi$>h&r#$dz4 zV9Q`PIe=M*L!ZHchryA-X>tp*7q<(8D?5W54}&{{$K;#LdK~%;UOWum3_g?jS(GjH z8T@z{{22lm89351b8>=GlS>#G*fl&oJv}wUI2l|Rf_NB$89W#nSe<+voxQmj^cg~V z7{VCBCug&$vPJSRL@`89p2nie9m^2M&JfSTkid{Q`523`ek?;W4?_w=A|nG^Mrvky zMhVETX*>++3_Oes>_w>siJ5sNTnroxnLG?x4B3+Z}@_85v7z#K0v)V8+ zwoL9}(_!qGypzq)R-HkEfq{Vu6aZklh#?V77lUX40R~nEHUp1_sT^>g*cz8^P+!7#JAD7+4t?7*ZKH8PXW|7}6P}8HyM*7+M+185kIN z7#Kl17%CVl!Ro6Rs-dRMW?*GtW?*1&)zXrd*~Xx_l|fZYYYT(wHU`ZD4EkFc47Ii} z7;a)P-NazMjlmwmao)z@31TrbOV`V6WAFvBH!%cmWAH?{Mvj4?#F_%}`e{Ft~yO8thV6P$)AnF)%XJfZY!AcNPOHSk3@q zo%1$^5Unls42I0iTH6>RwlKs%s3c?ug=lSKNJTgb5=4_3xEQ7|C^AfC&}Nv%pwBQJ z>=;N889*Jw0*XIq5G6qaTvAJWJ3|I2aE>wXYlCQJ=6c3$3_0N-8<-hDks!pt!oa`) z3e-6aJPdOgBpBv{O&0@4nIzP71_nunT826XMuvI@1_ovZMhOOHh6ZrVG%_@S>1Kvj i1_lNt1{MY;hGvE~1||kU1_+RXPz>!1W(=K7ESvxxDwU-G diff --git a/target/classes/beans/Drawing.class b/target/classes/beans/Drawing.class index 2d5c035e5297ff58be8442112dff9ea4e8db5288..8446deb921d5b3066c847610903ca43ed4a29d4f 100644 GIT binary patch delta 1772 zcmaE-zF&sx)W2Q(7#J9A8P0Cx;$;dI&Ppsxtk5qm&&*5L_i`#NDap^{V6bLnV0X?h z%}FgS;$pC1u;pQ3WsnE4?0Fa*7#tZHc#2a?-13u4ixZP_QW+UoG@>-agcukYoOu{r z7+fdEGP`qFFu3zDcrbWQUc+qd>CMQ%P1n4DUqP?BF-BE-PR;LOh8$H;){fZ&|W zl++?F2498%kez{y3~U;no}QXvAfaF$hLFh(EK;Gq3}HMB;UIVL7N?d3BxdH7gk&aX z7lRZ<@-Re!WcXk*K8Z=GImPS@F^mlSNvVl>#riHqi6HN)7;-U0GsJ=HiDzU`pZt+U zjT>xFA`e3nL-J&2R=eO-Mg~^*{M_7BAqFOpgEJTzgit~(ATcjBhl?Sdftj5l8|oYV z#PSk-x19WPpTx@i(h@F)EQSD(k~|)Ue1?L_l}uV(AZ`&4Loq|i`9IoSImwV8z8y%3#aRP(3-8O-i_yk%84Ozo;aGi-C`! z9%O36SBhF|_b7w1NVLt2nhJEVDQ>DJPYKp`DRI*f}FVvpBOz zp)@a5AsH6woeW*<4Bb2oJq*2*|FM-xXfX8iFic=zV`N}W&Ph!y0$DYQhhg$$3(m;N zn>aJ&lk@XRit=-c85u-;Fhj_CvILhbFHcTlZc<93N?vNYiqYgVT<$C@7#XA{U*wXS zJcrv$emx_D1ZoU{V#={7HBrTwonhnT=iIW4nv#5>Bvu$W=V{DQ96>0>rShg`VZ)9L#U}Bicz`)SOpv1tyAi%)Fz|FwTz{4QOz{?=UAjlxYAjF`? zAk3g$&mhKN&LGa<$RNew%^=MXz#zjA#URg+!l1yA$)Lzk%%H;1#GuO1!Jx*_%b?CM zi9v&5K7#?nDh5M_4GcyMyBSOwjxd-pTxBq4xWiz<@S4Gr;S+-u!!HJFMn(oZMotEM zMqvg=MhONdhG`5840e#9XPC|~gMop;o1y+3!%T)*42%pZ3|kpyGt6ROVrXKR&M=2z zE(0^eDu#T9c?`1{SQw5lgfh%$Sir!_z{D^a7LyD)49pBn3=9lXj6!W%TNrqEFm(86 zA7kLv(%#CztHr#PK@1cU%;1m^V_;=qU~psLW^iZVXYgPUVen*-Wbm#ByGjgV4AfQJ z4EziW8F&~N85S`xFmNz1{$Y@0XW$TE0wpy_B4S8lU;^tA1O>g=ECzO#dlZrE;egx20kKDb36z7NCRsvFV%6HlFtHxp92q2YSmEZd zLd;=cVOR}vCBqtqwG0dlppsUDVI9K;hD{973|kl&7!(+o8MZPoGwfm5%diK^Isj)K sX4u1Ui~$rTYz!Iykh<2{G9xv z_=3co)RK}^y@I@SE(SLSZ;&J8xfom+d_gQfMg~!cb6|FWOtIDs<6y83U}O+-&dAR! z&MZ>MNmNMAFU?6UEdpr`;$aA8kY{AzD^4v5$B_^j9DU{@wmIyI0GK8`- zBu(aHmIz5?NCCMpm63r>!_(7KGmM=fosmHbIXr?vf$W^0S6q^qS5nNykjRk9!;r?&F(U(u zMij{B#f%JsA&HqeIjIUMr3wX^dC94Xr641Mgcz6@%6J&c87deVc#2CBOH!RP67$ki zQy3XMCa+^woBW+wi3_B%iie?^p=R=ZW;^pbMg{?h&r^#Mi&LRqZ(w9#blv^DZhe| zK{&Z6HL)Z$EVZa4GdVFQxTL7Ggpom9!&7szBddrGJ3}ucgAlSVFQ3Gu)Eo|mentj1 zh(Ea)dKkRf8755@V3iV@!pOi9o?2YO#lXif4dkfllWke`RAw?VusNsZm82GdBxdt4 z%mD=dpbFFU25_Mc0M*EMh0^Y zpUHyE!YkF< z&i9*(;Sa-Kc7}gE4F4G!HkWa*FxJ1|XJusOV&G$B;bHj50OGNMcp+WMWXAtjHGcEKtU7@&b41u~@yBHFn3KAn(1dOz{FbHjDNVZ~;WMSFHkRiz; zz_pDb8_da*WDzRb#!w>3Qm-Y+vWuYO85|j;7(5xI8NwK38PXZ#7;+ip8Oj+H89Er082T8L8D=o3GOS=wV_3(a&ajn1 zgJCy=Cc_~HEr#<9It&jPbQxaMGw3mVW-wv+$zaOJ%wWdI$zaYX%wWN&$Y9B+!C=K` z#9+;6$zaFmz+lhl#o);3&)~#xiGhK^j)9GVfiZyLGQ$-H1_n$dJ!)hv5bTD+3e5d2oWLzreu2P{P2> zz{J47Ajc>)S8EFc?+%9fKHA3^1hurcGVp3KZ)FhE+QzUH6gte{(2)XJ&fvzt&EU?! z&)~rz!r;ju$>7Bx%isfcoEXG3sN=X9gc}J>!$;`Z+VVls7Z4A5o zw6-wl>TYA$x12#2uJ{lZ#Yd18BmAJpz|FwG5Kzy+&Je`F%@E8W!4Sfr$q>q5$PmV0 z!Vtk=!4S#d$`Hj6#t_XA#}Etlm z!obX60he`UkYsoYmJMUzV0Z?WWnhSh1_~%BSQwa0>NN$JK=~UQ40#Mp;II?b0)@jY z26mR^3@n%tz{kMMz`&r-Ai!Y2Ai`h>b{iznMWN<1Fo-g|WOxM)ba4hIA9e=5|Dg2E z&cMgc@S1^%oq>;0fT|kKf0$Zd2Q3SV$ z6P&mh85kHi8D28HXJ8Uw0+o7DLv0us!9L;u#n(25Q)p(^Gbn=%g}9yrZYT%D^#V+w z;uLC>CDbTZt!)fv(ad3xM>2*LZVW5L7zP%GPawZDd}jCpPJ_%08Vp|9k?K)`nh#VEum J!YIZd2>_v?{u}@R diff --git a/target/classes/com/mycompany/groupe_05/Groupe_05.class b/target/classes/com/mycompany/groupe_05/Groupe_05.class index c9e5944b6eb377556cd6227f25cdd9a55597c646..85b062eacd096a1801ddafe4aa55409b6b963478 100644 GIT binary patch delta 553 zcmaFKyo!zM)W2Q(7#J9A84M?KnJ_9&+$d2Wl3HBiR+N~V%EiFWz|79T&B(x)l$w}V ztRGmKT3nKupU1_(1(M)nWZ+Lp%-45G%ty%ZGB9&7@G=PUFbFXSGcvHGW#*+YG6-vU zYWkoWV$I1Q${@zhAkM=e!63=VAdr<VqWFMeIgSpX6Z8)GBOCDJDHJzB_%PxkdZ;q z2hHP?H5irZ6&RQpK!AyXk%5(gje(ItiGhJZpMjBqk%57MRcku~<3+&&A=YHoq;oaHv?DXb_O1w-3+{u z+Zp(Mby&7B2>5Jb5YgTi&LD*_UW$PYY!n9r7lQx;H-iKND4=*5R2ldgKvpV1jAhVd h&|+X<5MU5v&}PtKU}TVB;A7Bb&|?7kK_Bc`0{|Y1ZHoW^ delta 236 zcmZ3*_L7$?;smS^Urb1|?pFtamoPqdMqoWQtP zj0Ggl$iVM|qH3}clTtkw0}}%XFflMPurjbQFf#BkFfiydFfuSQFfg!cZD(NI$iTqB z#K6nI0G4K8U}fNAU|`^ZC}7}c5MW?n;A9YF5Q1uUWMBdt%DJ0?J#sq(rw_sah;1AU i91NUbL&OvyDj9?sL>L$tI2afiL>a`umWzXJl>h*AG#vr} diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index a601528..727e297 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,5 +1,14 @@ beans/Drawing$DrawArea$1.class +com/mycompany/groupe_05/TestFrame.class +dao/Dao.class +beans/Drawing$DrawArea$2.class +gui/QuestionsGui.class beans/Drawing$DrawArea.class +gui/QuestionsGui$1.class +beans/Drawing$1.class +sql/MariaDbConnection.class +beans/Question.class beans/Drawing.class com/mycompany/groupe_05/Groupe_05.class -beans/Drawing$DrawArea$2.class +dao/DaoQuestion.class +beans/Drawing$DrawArea$3.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index db64fcc..2de4cb1 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,2 +1,8 @@ -/home/stag/Documents/07 - Java JSE/projet/Groupe_05/src/main/java/com/mycompany/groupe_05/Groupe_05.java -/home/stag/Documents/07 - Java JSE/projet/Groupe_05/src/main/java/beans/Drawing.java +/home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/sql/MariaDbConnection.java +/home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/beans/Question.java +/home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/com/mycompany/groupe_05/TestFrame.java +/home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/dao/Dao.java +/home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/dao/DaoQuestion.java +/home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/gui/QuestionsGui.java +/home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/beans/Drawing.java +/home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/com/mycompany/groupe_05/Groupe_05.java -- GitLab From 07b8fbfdaac8a50a1521ebb7e886a90eecf7e12b Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 18 Sep 2024 16:08:47 +0200 Subject: [PATCH 3/8] + gitignore --- .gitignore | 238 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fc0db2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,238 @@ +# Created by https://www.toptal.com/developers/gitignore/api/java,netbeans,maven,eclipse,intellij +# Edit at https://www.toptal.com/developers/gitignore?templates=java,netbeans,maven,eclipse,intellij + +### Eclipse ### +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ +.apt_generated_test/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Uncomment this line if you wish to ignore the project description file. +# Typically, this file would be tracked if it contains build/dependency configurations: +#.project + +### Eclipse Patch ### +# Spring Boot Tooling +.sts4-cache/ + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +### NetBeans ### +**/nbproject/private/ +**/nbproject/Makefile-*.mk +**/nbproject/Package-*.bash +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +# End of https://www.toptal.com/developers/gitignore/api/java,netbeans,maven,eclipse,intellij -- GitLab From 510924dcb51f37af53d0f03cbb9abb1847e7231c Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 18 Sep 2024 17:14:46 +0200 Subject: [PATCH 4/8] =?UTF-8?q?tests=20valid=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/beans/Question.java | 12 +----------- src/main/java/dao/DaoQuestion.java | 26 ++++++++++++-------------- src/test/java/dao/DaoQuestionTest.java | 5 ++++- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/main/java/beans/Question.java b/src/main/java/beans/Question.java index 2d5f01b..4ebb82e 100644 --- a/src/main/java/beans/Question.java +++ b/src/main/java/beans/Question.java @@ -10,22 +10,13 @@ package beans; */ public class Question { private int id; - private int number; private int level; private String statement; private String answer; public Question() { } - - public int getNumber() { - return number; - } - - public void setNumber(int number) { - this.number = number; - } - + public void setId(int id) { this.id = id; } @@ -63,7 +54,6 @@ public class Question { StringBuilder sb = new StringBuilder(); sb.append("Questions{"); sb.append("id=").append(id); - sb.append(", number=").append(number); sb.append(", level=").append(level); sb.append(", statement=").append(statement); sb.append(", answer=").append(answer); diff --git a/src/main/java/dao/DaoQuestion.java b/src/main/java/dao/DaoQuestion.java index 608ed64..51f7d2b 100644 --- a/src/main/java/dao/DaoQuestion.java +++ b/src/main/java/dao/DaoQuestion.java @@ -24,12 +24,11 @@ public class DaoQuestion implements Dao { private Question createBean(ResultSet rs) { Question obj = new Question(); try { - obj.setNumber(rs.getInt("number")); obj.setLevel(rs.getInt("level")); obj.setStatement(rs.getString("statement")); obj.setAnswer(rs.getString("answer")); } catch (SQLException ex) { - System.out.println("Impossible de parcourir le resultSet"); + System.out.println("Impossible de parcourir le resultSet" + ex.getMessage()); } return obj; } @@ -40,12 +39,12 @@ public class DaoQuestion implements Dao { String sql = "SELECT * FROM questions WHERE id=?"; try (PreparedStatement pstmt = connect.prepareStatement(sql)) { pstmt.setInt(1, id); - ResultSet rs = pstmt.executeQuery(sql); + ResultSet rs = pstmt.executeQuery(); if (rs.next()) { q = createBean(rs); } } catch (SQLException ex) { - throw new RuntimeException("Recherche impossible dans la table questions"); + throw new RuntimeException("Recherche impossible dans la table questions" + ex.getMessage()); } return q; } @@ -63,7 +62,7 @@ public class DaoQuestion implements Dao { obj.setId(keys.getInt(1)); } } catch (SQLException ex) { - throw new RuntimeException("Insertion impossible dans la table questions"); + throw new RuntimeException("Insertion impossible dans la table questions\t Message: " + ex.getMessage()); } } @@ -74,22 +73,21 @@ public class DaoQuestion implements Dao { pstmt.setInt(1, id); pstmt.executeUpdate(); } catch (SQLException ex) { - throw new RuntimeException("Suppression impossible dans la table questions"); + throw new RuntimeException("Suppression impossible dans la table questions" + ex.getMessage()); } } @Override public void update(Question obj) { - String sql = "UPDATE questions SET number=?, level=?, statement=?, answer=? WHERE id=?"; + String sql = "UPDATE questions SET level=?, statement=?, answer=? WHERE id=?"; try (PreparedStatement pstmt = connect.prepareStatement(sql)) { - pstmt.setInt(1, obj.getNumber()); - pstmt.setInt(2, obj.getLevel()); - pstmt.setString(3, obj.getStatement()); - pstmt.setString(4, obj.getAnswer()); + pstmt.setInt(1, obj.getLevel()); + pstmt.setString(2, obj.getStatement()); + pstmt.setString(3, obj.getAnswer()); pstmt.setInt(4, obj.getId()); pstmt.executeUpdate(); } catch (SQLException ex) { - throw new RuntimeException("Update impossible dans la table questions"); + throw new RuntimeException("Update impossible dans la table questions" + ex.getMessage()); } } @@ -98,12 +96,12 @@ public class DaoQuestion implements Dao { Collection list = new ArrayList<>(); String sql = "SELECT * FROM questions"; try (PreparedStatement pstmt = connect.prepareStatement(sql)) { - ResultSet rs =pstmt.executeQuery(); + ResultSet rs = pstmt.executeQuery(); while (rs.next()) { list.add(createBean(rs)); } } catch (SQLException ex) { - System.out.println("Récupération impossible de la table questions"); + System.out.println("Récupération impossible de la table questions" + ex.getMessage()); } return list; } diff --git a/src/test/java/dao/DaoQuestionTest.java b/src/test/java/dao/DaoQuestionTest.java index 4747cb5..1ddd5e6 100644 --- a/src/test/java/dao/DaoQuestionTest.java +++ b/src/test/java/dao/DaoQuestionTest.java @@ -29,16 +29,19 @@ public class DaoQuestionTest { System.out.println("Test de la méthode create"); q.setStatement("test"); + q.setAnswer("test"); q.setLevel(100); assertDoesNotThrow(() -> daoq.create(q)); assertNotNull(q.getId()); System.out.println("Test de la méthode update"); q.setStatement("pouet"); + q.setAnswer("pouet"); q.setLevel(50); assertDoesNotThrow(() -> daoq.update(q)); assertEquals("pouet", daoq.find(q.getId()).getStatement()); - assertEquals("50", daoq.find(q.getId()).getLevel()); + assertEquals("pouet", daoq.find(q.getId()).getAnswer()); + assertEquals(50, daoq.find(q.getId()).getLevel()); System.out.println("Test de la méthode delete"); assertDoesNotThrow(() -> daoq.delete(q.getId())); -- GitLab From 6243e972030121793609897a2c3b29fc897a33f8 Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 18 Sep 2024 19:06:07 +0200 Subject: [PATCH 5/8] evenementiel questions --- src/main/java/beans/Question.java | 24 +++- .../com/mycompany/groupe_05/Groupe_05.java | 2 +- src/main/java/gui/QuestionsGui.java | 106 ++++++++++++++++-- .../com/mycompany/groupe_05/Groupe_05.class | Bin 810 -> 668 bytes .../compile/default-compile/createdFiles.lst | 2 + 5 files changed, 120 insertions(+), 14 deletions(-) diff --git a/src/main/java/beans/Question.java b/src/main/java/beans/Question.java index 4ebb82e..80759c1 100644 --- a/src/main/java/beans/Question.java +++ b/src/main/java/beans/Question.java @@ -4,11 +4,15 @@ */ package beans; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Random; + /** * * @author Clément GROSSELLE */ -public class Question { +public class Question implements Serializable { private int id; private int level; private String statement; @@ -17,6 +21,13 @@ public class Question { public Question() { } + public Question(Question q) { + this.id = q.id; + this.level = q.level; + this.statement = q.statement; + this.answer = q.answer; + } + public void setId(int id) { this.id = id; } @@ -61,7 +72,12 @@ public class Question { return sb.toString(); } - - - +// public Question selectRandomQuestion(ArrayList qlist) { +// Random randGen = new Random(); +// Question q = new Question(); +// int rand = randGen.nextInt(qlist.size()); +// return qlist.get(rand); +// } +// +// } diff --git a/src/main/java/com/mycompany/groupe_05/Groupe_05.java b/src/main/java/com/mycompany/groupe_05/Groupe_05.java index 1efa59c..6fcd55d 100644 --- a/src/main/java/com/mycompany/groupe_05/Groupe_05.java +++ b/src/main/java/com/mycompany/groupe_05/Groupe_05.java @@ -10,7 +10,7 @@ public class Groupe_05 { Question q = new Question(); DaoQuestion daoq = new DaoQuestion(); q = daoq.find(1); - System.out.println(q); + //System.out.println(q); } diff --git a/src/main/java/gui/QuestionsGui.java b/src/main/java/gui/QuestionsGui.java index 42158d2..11aba1d 100644 --- a/src/main/java/gui/QuestionsGui.java +++ b/src/main/java/gui/QuestionsGui.java @@ -4,9 +4,16 @@ */ package gui; +import beans.Question; +import dao.DaoQuestion; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.Serializable; +import java.text.Normalizer; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Random; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; @@ -16,55 +23,136 @@ import javax.swing.JTextField; /** * - * @author CLément GROSSELLE + * @author Clément GROSSELLE */ -public class QuestionsGui extends JPanel { - JPanel questionsPane, statmentPane, answerPane, buttonsPane; - JLabel sLabel, aLabel; +public class QuestionsGui extends JPanel implements Serializable{ + + private static final long serialVersionUID = 1L; + + JPanel questionsPane, statmentPane, helpPane, answerPane, buttonsPane; + JLabel sLabel, aLabel, hLabel; JTextField atf; JButton confirmButton, showButton, nextButton; - + Question q = new Question(); + Collection qlist = new ArrayList<>(); + public QuestionsGui() { + qlist = initQuestion(); + System.out.println("qlist: " + qlist); + q = selectRandomQuestion((ArrayList) qlist); questionsPane = new JPanel(); statmentPane = new JPanel(); + helpPane = new JPanel(); answerPane = new JPanel(); buttonsPane = new JPanel(); confirmButton = new JButton("Valider réponse"); showButton = new JButton("Afficher réponse"); nextButton = new JButton("Question suivante"); - sLabel = new JLabel("Ici la question"); + sLabel = new JLabel(q.getStatement()); + hLabel = new JLabel("blabla"); aLabel = new JLabel("Saisissez votre réponse"); atf = new JTextField(30); initGui(); initEvent(); + System.out.println("q: " + q); + System.out.println("lab: " + sLabel.getText()); + System.out.println("qlist: " + qlist); } - + private void initGui() { + // Design this.setBorder(BorderFactory.createLineBorder(Color.red)); questionsPane.setLayout(new BoxLayout(questionsPane, BoxLayout.Y_AXIS)); answerPane.setLayout(new BoxLayout(answerPane, BoxLayout.Y_AXIS)); statmentPane.setBorder(BorderFactory.createLineBorder(Color.yellow)); answerPane.setBorder(BorderFactory.createLineBorder(Color.green)); buttonsPane.setBorder(BorderFactory.createLineBorder(Color.blue)); + + //Ajout des composants + //Question statmentPane.add(sLabel); + //Aide + helpPane.add(hLabel); + //Saisie utilisateur answerPane.add(aLabel); answerPane.add(atf); + //Boutons buttonsPane.add(confirmButton); buttonsPane.add(showButton); buttonsPane.add(nextButton); + + // Panneau principal de l'activité questionsPane.add(statmentPane); + questionsPane.add(helpPane); questionsPane.add(answerPane); questionsPane.add(buttonsPane); - this.add(questionsPane); + // Pas sur pour ça + this.add(questionsPane); + } private void initEvent() { confirmButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { - System.out.println("bouton validé"); + String usrTxt = atf.getText().toLowerCase(); + String answer = q.getAnswer().toLowerCase(); + System.out.println("bouton validé\nTexte saisi: " + usrTxt); + usrTxt = removeAccents(usrTxt); + System.out.println("Après traitement: " + usrTxt); + if (usrTxt.equals(answer)) { + //Pop-up validé + System.out.println("oui"); + + } else { + System.out.println("nop"); + } + } + }); + showButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ae) { + System.out.println("bouton afficher"); + } + }); + nextButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ae) { + System.out.println("bouton suivant"); + if (!qlist.isEmpty()) { + q = selectRandomQuestion((ArrayList) qlist); + sLabel.setText(q.getStatement()); + } else { + // Ici pop-up d'erreur qui prend le focus + } } }); } + + private Collection initQuestion() { + DaoQuestion daoq = new DaoQuestion(); + return daoq.all(); + } + + private Question selectRandomQuestion(ArrayList qlist) { + Random randGen = new Random(); + //Question q = new Question(); + int rand = randGen.nextInt(qlist.size()); + q = qlist.get(rand); + try { + qlist.remove(rand); + } catch (IllegalArgumentException iae) { + throw new IllegalArgumentException("La liste des question est vide"); + } + return q; + } + + public String removeAccents(String text) { + if (text== null) + return null; + String replaceAll = Normalizer.normalize(text, Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); + return replaceAll; + } + } diff --git a/target/classes/com/mycompany/groupe_05/Groupe_05.class b/target/classes/com/mycompany/groupe_05/Groupe_05.class index 85b062eacd096a1801ddafe4aa55409b6b963478..78dca1628b6f5d3929f5e096eb60e2bce3725a62 100644 GIT binary patch delta 208 zcmZ3*Hiwn#)W2Q(7#J9A8B`~7ZDnR>5S?fvJvo8#ON0($ps>Gi!rc*RdO(JF$gelGe|J-Fvv0RGk{D}faqY5WsqZFU=U#7XOL%5 WU|?jBU|?rZWKd!NIZqkv4ix|;HxbGJ delta 354 zcmbQkx{8hK)W2Q(7#J9A84M?KZLQ~I5M>Z!XAtLMkYJExWDv+oEKAhSNz6;v53VdO zNzG+sV9qZsVPp{X0n23O>jxBN=9L7O6s0EST5~Z-Gsv(r$nr4AF~~DA2xC#h$iQ9z z(vg$L$RMf#F$HYCe^ORzGFOSUW*9qzA|r$1WO+u#iO*igC@?TFfB+K%BLgb~8v`SQ z5(5K+J_92IBLf2itJZb~#*GXN3``8l3=Cjt5UIkzz`z4hz@W;Y#=yY9$)L`l0o7c= zz{J4Jz`&q3S(iyJW)p*m_BIA7gdtK4Y+wx>3|tHX4BQM73?TpTGN>}}Gk^?MfM{mW iWYA(@U=UysW6);MVPIsCVBllWWzb^)xl|wQBm)3^8aL|z diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 727e297..29a1d2b 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -2,6 +2,7 @@ beans/Drawing$DrawArea$1.class com/mycompany/groupe_05/TestFrame.class dao/Dao.class beans/Drawing$DrawArea$2.class +gui/QuestionsGui$2.class gui/QuestionsGui.class beans/Drawing$DrawArea.class gui/QuestionsGui$1.class @@ -11,4 +12,5 @@ beans/Question.class beans/Drawing.class com/mycompany/groupe_05/Groupe_05.class dao/DaoQuestion.class +gui/QuestionsGui$3.class beans/Drawing$DrawArea$3.class -- GitLab From 142f0ef891d157bbb6bca355797281b3c9426b0c Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 19 Sep 2024 11:16:26 +0200 Subject: [PATCH 6/8] =?UTF-8?q?activit=C3=A9=20question=20~ok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/beans/Question.java | 9 - .../com/mycompany/groupe_05/TestFrame.java | 2 +- src/main/java/gui/QuestionsGui.java | 161 ++++++++++++------ src/main/resources/db.sql | 17 +- src/test/java/dao/DaoQuestionTest.java | 2 +- .../compile/default-compile/createdFiles.lst | 2 - 6 files changed, 123 insertions(+), 70 deletions(-) diff --git a/src/main/java/beans/Question.java b/src/main/java/beans/Question.java index 80759c1..0372ce9 100644 --- a/src/main/java/beans/Question.java +++ b/src/main/java/beans/Question.java @@ -71,13 +71,4 @@ public class Question implements Serializable { sb.append('}'); return sb.toString(); } - -// public Question selectRandomQuestion(ArrayList qlist) { -// Random randGen = new Random(); -// Question q = new Question(); -// int rand = randGen.nextInt(qlist.size()); -// return qlist.get(rand); -// } -// -// } diff --git a/src/main/java/com/mycompany/groupe_05/TestFrame.java b/src/main/java/com/mycompany/groupe_05/TestFrame.java index fd559ce..caca067 100644 --- a/src/main/java/com/mycompany/groupe_05/TestFrame.java +++ b/src/main/java/com/mycompany/groupe_05/TestFrame.java @@ -20,7 +20,7 @@ public class TestFrame extends JFrame { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setResizable(true); this.pack(); - //this.setSize(300, 500); + //this.setSize(600, 600); this.setLocationRelativeTo(null); this.setVisible(true); } diff --git a/src/main/java/gui/QuestionsGui.java b/src/main/java/gui/QuestionsGui.java index 11aba1d..00d62d9 100644 --- a/src/main/java/gui/QuestionsGui.java +++ b/src/main/java/gui/QuestionsGui.java @@ -6,26 +6,28 @@ package gui; import beans.Question; import dao.DaoQuestion; -import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.Serializable; import java.text.Normalizer; import java.util.ArrayList; import java.util.Collection; import java.util.Random; +import javax.swing.AbstractAction; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.KeyStroke; /** * * @author Clément GROSSELLE */ -public class QuestionsGui extends JPanel implements Serializable{ +public class QuestionsGui extends JPanel { private static final long serialVersionUID = 1L; @@ -35,97 +37,139 @@ public class QuestionsGui extends JPanel implements Serializable{ JButton confirmButton, showButton, nextButton; Question q = new Question(); Collection qlist = new ArrayList<>(); + Font labelFont = new Font(Font.SANS_SERIF, Font.BOLD, 20); + Font helpFont = new Font(Font.SANS_SERIF, Font.ITALIC, 12); + Font buttonFont = new Font(Font.SANS_SERIF, Font.PLAIN, 15); + Font textFieldFont = new Font(Font.SANS_SERIF, Font.PLAIN, 20); public QuestionsGui() { qlist = initQuestion(); - System.out.println("qlist: " + qlist); + //System.out.println("qlist: " + qlist); q = selectRandomQuestion((ArrayList) qlist); + + // Initialisation des panneaux et composants questionsPane = new JPanel(); statmentPane = new JPanel(); helpPane = new JPanel(); answerPane = new JPanel(); buttonsPane = new JPanel(); + confirmButton = new JButton("Valider réponse"); showButton = new JButton("Afficher réponse"); nextButton = new JButton("Question suivante"); - sLabel = new JLabel(q.getStatement()); - hLabel = new JLabel("blabla"); - aLabel = new JLabel("Saisissez votre réponse"); - atf = new JTextField(30); + + // Config labels: + // Question + sLabel = new JLabel("" + q.getStatement() + ""); + sLabel.setFont(labelFont); + sLabel.setHorizontalAlignment(JLabel.CENTER); + + // Aide + hLabel = new JLabel(" ", JLabel.CENTER); + hLabel.setFont(helpFont); + hLabel.setHorizontalAlignment(JLabel.CENTER); + + // Réponse + aLabel = new JLabel("Saisissez votre réponse", JLabel.CENTER); + aLabel.setFont(helpFont); + aLabel.setHorizontalAlignment(JLabel.CENTER); + + atf = new JTextField(); + + // Paramétrage des dfférentes font + confirmButton.setFont(buttonFont); + showButton.setFont(buttonFont); + nextButton.setFont(buttonFont); + atf.setFont(textFieldFont); + initGui(); initEvent(); - System.out.println("q: " + q); - System.out.println("lab: " + sLabel.getText()); - System.out.println("qlist: " + qlist); + } private void initGui() { - // Design - this.setBorder(BorderFactory.createLineBorder(Color.red)); + // Layout questionsPane.setLayout(new BoxLayout(questionsPane, BoxLayout.Y_AXIS)); answerPane.setLayout(new BoxLayout(answerPane, BoxLayout.Y_AXIS)); - statmentPane.setBorder(BorderFactory.createLineBorder(Color.yellow)); - answerPane.setBorder(BorderFactory.createLineBorder(Color.green)); - buttonsPane.setBorder(BorderFactory.createLineBorder(Color.blue)); - + + //Size + //questionsPane.setPreferredSize(new Dimension(600, 600)); + statmentPane.setPreferredSize(new Dimension(300, 50)); + helpPane.setPreferredSize(new Dimension(200, 50)); + //answerPane.setPreferredSize(new Dimension(50, 20)); + //buttonsPane.setPreferredSize(new Dimension(600, 150)); + + //Border + questionsPane.setBorder(BorderFactory.createEmptyBorder(30, 10, 10, 10)); + //this.setBorder(BorderFactory.createLineBorder(Color.green)); + //questionsPane.setBorder(BorderFactory.createLineBorder(Color.green)); + //statmentPane.setBorder(BorderFactory.createLineBorder(Color.yellow)); + //answerPane.setBorder(BorderFactory.createLineBorder(Color.green)); + //buttonsPane.setBorder(BorderFactory.createLineBorder(Color.blue)); + //Ajout des composants - //Question + //Question statmentPane.add(sLabel); - //Aide + //Aide helpPane.add(hLabel); - //Saisie utilisateur + //Saisie utilisateur answerPane.add(aLabel); answerPane.add(atf); - //Boutons + //Boutons buttonsPane.add(confirmButton); buttonsPane.add(showButton); buttonsPane.add(nextButton); - + // Panneau principal de l'activité questionsPane.add(statmentPane); questionsPane.add(helpPane); questionsPane.add(answerPane); questionsPane.add(buttonsPane); - + // Pas sur pour ça this.add(questionsPane); - } private void initEvent() { - confirmButton.addActionListener(new ActionListener() { + // Méthode validation réponse, clic confirmButton ou Enter + AbstractAction confirmAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent ae) { - String usrTxt = atf.getText().toLowerCase(); - String answer = q.getAnswer().toLowerCase(); - System.out.println("bouton validé\nTexte saisi: " + usrTxt); - usrTxt = removeAccents(usrTxt); - System.out.println("Après traitement: " + usrTxt); - if (usrTxt.equals(answer)) { + if (compareStrings(atf.getText(), q.getAnswer())) { //Pop-up validé System.out.println("oui"); - + hLabel.setText("Bravo, tu as trouvé la bonne réponse!"); + changeQuestion(); + atf.setText(""); } else { System.out.println("nop"); + hLabel.setText("Oh non c'est raté! Essaye encore."); } } + }; + //Association au boutton confirm + confirmButton.addActionListener(confirmAction); + // Et à la touche entrée + atf.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "confirm"); + atf.getActionMap().put("confirm", confirmAction); + + // Clic boutton afficher réponse + showButton.addActionListener((ActionEvent ae) -> { + System.out.println("bouton afficher"); + hLabel.setText("La réponse attendue est :\n " + q.getAnswer()); }); - showButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent ae) { - System.out.println("bouton afficher"); - } - }); - nextButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent ae) { - System.out.println("bouton suivant"); - if (!qlist.isEmpty()) { - q = selectRandomQuestion((ArrayList) qlist); - sLabel.setText(q.getStatement()); - } else { - // Ici pop-up d'erreur qui prend le focus - } + + // Clic bouton suivant + nextButton.addActionListener((ActionEvent ae) -> { + hLabel.setText(""); + System.out.println("bouton suivant\n Nombre de questions restantes:" + qlist.size()); + if (!qlist.isEmpty()) { + // Si il reste des question dans la liste, on passa a la suivante + changeQuestion(); + } else { + // Sinon on réinjecte les questions de la bdd et zérapatis + qlist = initQuestion(); + changeQuestion(); } }); } @@ -147,12 +191,25 @@ public class QuestionsGui extends JPanel implements Serializable{ } return q; } - - public String removeAccents(String text) { - if (text== null) + + private String removeAccents(String text) { + if (text == null) { return null; + } String replaceAll = Normalizer.normalize(text, Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); return replaceAll; } + private boolean compareStrings(String inString, String ansString) { + inString = inString.toLowerCase(); + ansString = ansString.toLowerCase(); + inString = removeAccents(inString); + return inString.equals(ansString); + } + + private void changeQuestion() { + q = selectRandomQuestion((ArrayList) qlist); + sLabel.setText(q.getStatement()); + } + } diff --git a/src/main/resources/db.sql b/src/main/resources/db.sql index 904bb6e..30429e0 100644 --- a/src/main/resources/db.sql +++ b/src/main/resources/db.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Hôte : localhost --- Généré le : mer. 18 sep. 2024 à 10:40 +-- Généré le : jeu. 19 sep. 2024 à 09:03 -- Version du serveur : 10.1.48-MariaDB-0+deb9u2 -- Version de PHP : 7.4.33 @@ -30,7 +30,6 @@ SET time_zone = "+00:00"; CREATE TABLE `questions` ( `id` int(11) NOT NULL, - `number` int(11) NOT NULL, `level` int(11) NOT NULL, `statement` text NOT NULL, `answer` text NOT NULL @@ -40,8 +39,16 @@ CREATE TABLE `questions` ( -- Déchargement des données de la table `questions` -- -INSERT INTO `questions` (`id`, `number`, `level`, `statement`, `answer`) VALUES -(1, 1, 1, 'Comment ça va?', 'bieng'); +INSERT INTO `questions` (`id`, `level`, `statement`, `answer`) VALUES +(1, 1, 'Combien y a-t-il de doigts sur une main?', 'Cinq'), +(2, 1, 'De quelle couleur est le ciel?', 'Bleu'), +(3, 1, 'De quelle couleur est le cheval blanc d\'Henry IV?', 'Blanc'), +(4, 1, 'Quel animal fait miaou?', 'Chat'), +(5, 1, 'De quelle couleur est une tomate bien mûre?', 'Rouge'), +(6, 1, 'Combien y a-t-il de saisons dans une année?', 'Quatre'), +(7, 1, 'Combien de côtés a un carré?', 'Quatre'), +(8, 1, 'Quelle est la couleur de l\'herbe?', 'Verte') +; -- -- Index pour les tables déchargées @@ -61,7 +68,7 @@ ALTER TABLE `questions` -- AUTO_INCREMENT pour la table `questions` -- ALTER TABLE `questions` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/src/test/java/dao/DaoQuestionTest.java b/src/test/java/dao/DaoQuestionTest.java index 1ddd5e6..323ee8b 100644 --- a/src/test/java/dao/DaoQuestionTest.java +++ b/src/test/java/dao/DaoQuestionTest.java @@ -53,7 +53,7 @@ public class DaoQuestionTest { DaoQuestion daoq =new DaoQuestion(); System.out.println("Test de la méthode all"); assertDoesNotThrow(() -> daoq.all()); - assertEquals(daoq.all().size(), 1); + assertEquals(daoq.all().size(), 8); } } diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 29a1d2b..727e297 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -2,7 +2,6 @@ beans/Drawing$DrawArea$1.class com/mycompany/groupe_05/TestFrame.class dao/Dao.class beans/Drawing$DrawArea$2.class -gui/QuestionsGui$2.class gui/QuestionsGui.class beans/Drawing$DrawArea.class gui/QuestionsGui$1.class @@ -12,5 +11,4 @@ beans/Question.class beans/Drawing.class com/mycompany/groupe_05/Groupe_05.class dao/DaoQuestion.class -gui/QuestionsGui$3.class beans/Drawing$DrawArea$3.class -- GitLab From a8e0cc7d98baa05e520e172b5a1a75341b9686a5 Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 19 Sep 2024 12:14:35 +0200 Subject: [PATCH 7/8] avant merge --- src/main/java/com/mycompany/groupe_05/Groupe_05.java | 6 ------ src/main/resources/db.sql | 9 +++++---- .../compile/default-compile/createdFiles.lst | 1 + .../compile/default-compile/inputFiles.lst | 1 + 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/mycompany/groupe_05/Groupe_05.java b/src/main/java/com/mycompany/groupe_05/Groupe_05.java index 6fcd55d..e1952cb 100644 --- a/src/main/java/com/mycompany/groupe_05/Groupe_05.java +++ b/src/main/java/com/mycompany/groupe_05/Groupe_05.java @@ -6,12 +6,6 @@ import dao.DaoQuestion; public class Groupe_05 { public static void main(String[] args) { - new TestFrame(); - Question q = new Question(); - DaoQuestion daoq = new DaoQuestion(); - q = daoq.find(1); - //System.out.println(q); - } } diff --git a/src/main/resources/db.sql b/src/main/resources/db.sql index 30429e0..a7ad42b 100644 --- a/src/main/resources/db.sql +++ b/src/main/resources/db.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Hôte : localhost --- Généré le : jeu. 19 sep. 2024 à 09:03 +-- Généré le : jeu. 19 sep. 2024 à 12:14 -- Version du serveur : 10.1.48-MariaDB-0+deb9u2 -- Version de PHP : 7.4.33 @@ -47,8 +47,9 @@ INSERT INTO `questions` (`id`, `level`, `statement`, `answer`) VALUES (5, 1, 'De quelle couleur est une tomate bien mûre?', 'Rouge'), (6, 1, 'Combien y a-t-il de saisons dans une année?', 'Quatre'), (7, 1, 'Combien de côtés a un carré?', 'Quatre'), -(8, 1, 'Quelle est la couleur de l\'herbe?', 'Verte') -; +(8, 1, 'Quelle est la couleur de l\'herbe?', 'Verte'), +(13, 1, 'Quel est le meilleur formateur?', 'Herbert'), +(15, 1, 'Quel est le meilleur formateur?', 'Herbert'); -- -- Index pour les tables déchargées @@ -68,7 +69,7 @@ ALTER TABLE `questions` -- AUTO_INCREMENT pour la table `questions` -- ALTER TABLE `questions` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 727e297..96a1727 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -12,3 +12,4 @@ beans/Drawing.class com/mycompany/groupe_05/Groupe_05.class dao/DaoQuestion.class beans/Drawing$DrawArea$3.class +gui/NewQuestion.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 2de4cb1..5adef75 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -2,6 +2,7 @@ /home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/beans/Question.java /home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/com/mycompany/groupe_05/TestFrame.java /home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/dao/Dao.java +/home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/gui/NewQuestion.java /home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/dao/DaoQuestion.java /home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/gui/QuestionsGui.java /home/stag/NetBeansProjects/projet_java/projet_groupe05/src/main/java/beans/Drawing.java -- GitLab From 887c9aecb547ddc3822e1d3b372b9ff66599e9a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20GROSSELLE?= Date: Thu, 19 Sep 2024 10:17:01 +0000 Subject: [PATCH 8/8] Update Groupe_05.java --- src/main/java/com/mycompany/groupe_05/Groupe_05.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/mycompany/groupe_05/Groupe_05.java b/src/main/java/com/mycompany/groupe_05/Groupe_05.java index e1952cb..2a77405 100644 --- a/src/main/java/com/mycompany/groupe_05/Groupe_05.java +++ b/src/main/java/com/mycompany/groupe_05/Groupe_05.java @@ -1,8 +1,5 @@ package com.mycompany.groupe_05; -import beans.Question; -import dao.DaoQuestion; - public class Groupe_05 { public static void main(String[] args) { -- GitLab