diff --git a/02_Calcul/.~lock.exemple_visu01.odt# b/02_Calcul/.~lock.exemple_visu01.odt# new file mode 100644 index 0000000000000000000000000000000000000000..ed9acdcaddfcebdc711e55dcd9b3b805d8c898d4 --- /dev/null +++ b/02_Calcul/.~lock.exemple_visu01.odt# @@ -0,0 +1 @@ +,stag,formation-ldnr-5CG6385VLR,19.09.2024 11:37,file:///home/stag/.config/libreoffice/4; \ No newline at end of file diff --git a/02_Calcul/Activite_calcul/.gitignore b/02_Calcul/Activite_calcul/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..da73cf060ffc904e1b537f47cc4a444fbf8f7db4 --- /dev/null +++ b/02_Calcul/Activite_calcul/.gitignore @@ -0,0 +1,238 @@ +# Created by https://www.toptal.com/developers/gitignore/api/eclipse,java,intellij,netbeans,maven +# Edit at https://www.toptal.com/developers/gitignore?templates=eclipse,java,intellij,netbeans,maven + +### 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/eclipse,java,intellij,netbeans,maven diff --git a/02_Calcul/Activite_calcul/nbactions.xml b/02_Calcul/Activite_calcul/nbactions.xml new file mode 100644 index 0000000000000000000000000000000000000000..15f91b5b0a196c9b088dff94aed7019b9709452b --- /dev/null +++ b/02_Calcul/Activite_calcul/nbactions.xml @@ -0,0 +1,55 @@ + + + + run + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:3.1.0:exec + + + + ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} + + Calcul.Main + java + + + + debug + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:3.1.0:exec + + + -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} + ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} + + Calcul.Main + java + true + + + + profile + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:3.1.0:exec + + + + ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} + Calcul.Main + java + + + + diff --git a/02_Calcul/Activite_calcul/pom.xml b/02_Calcul/Activite_calcul/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..649fbd6d0079615a954e72bdcd041266964a9b23 --- /dev/null +++ b/02_Calcul/Activite_calcul/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + activite + Activite_calcul + 01 + jar + + UTF-8 + 17 + 17 + activité_calcul.Activite_calcul + + Activite_calcul + \ No newline at end of file diff --git a/02_Calcul/Activite_calcul/src/main/java/Calcul/Main.java b/02_Calcul/Activite_calcul/src/main/java/Calcul/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..6629938c5e38942abaf9f437b278c5bb4a97a49c --- /dev/null +++ b/02_Calcul/Activite_calcul/src/main/java/Calcul/Main.java @@ -0,0 +1,13 @@ +package Calcul; + +/** + * + * @author stag + */ +public class Main { + + public static void main(String[] args) { + TestCalcul test = new TestCalcul(); + } + +} diff --git a/02_Calcul/Activite_calcul/src/main/java/Calcul/TestCalcul.java b/02_Calcul/Activite_calcul/src/main/java/Calcul/TestCalcul.java new file mode 100644 index 0000000000000000000000000000000000000000..1ac6682b6a854f20cab98b1c0ef3f91d28f917fa --- /dev/null +++ b/02_Calcul/Activite_calcul/src/main/java/Calcul/TestCalcul.java @@ -0,0 +1,65 @@ +package Calcul; + +import beans.Addition; +import beans.Substraction; +import java.util.Random; +import javax.swing.Box; +import javax.swing.JFrame; +import javax.swing.JPanel; + +/** + * + * @author cedric + */ +public class TestCalcul extends JFrame { + + private JPanel[] panels; + private JPanel currentPanel; + + private final Box content; + private final Addition additionPanel; + private final Substraction substractionPanel; + + public TestCalcul() { + this.setTitle("Seras-tu résoudre ce calcul"); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + this.content = Box.createVerticalBox(); + + this.additionPanel = new Addition(); + this.substractionPanel = new Substraction(); + + panels = new JPanel[]{additionPanel, substractionPanel}; + + this.TestPanel(); + + //Appel de la méthode pour afficher un panel aléatoire + this.TestPanel(); + + this.setSize(800, 600); + this.setVisible(true); + + } + + private void TestPanel() { + + Random rand = new Random(); + int randomIndex = rand.nextInt(panels.length); + + if (currentPanel != null) { + this.remove(currentPanel); // Retirer le panel précédent + } + + currentPanel = panels[randomIndex]; + this.add(currentPanel); + + // Rafraîchir l'affichage + this.revalidate(); + this.repaint(); + } + + private void initGui() { + this.add(content); + } + +} diff --git a/02_Calcul/Activite_calcul/src/main/java/beans/Addition.java b/02_Calcul/Activite_calcul/src/main/java/beans/Addition.java new file mode 100644 index 0000000000000000000000000000000000000000..226cf96d1b420ff3f3558c7c4d6b0f617e8516fd --- /dev/null +++ b/02_Calcul/Activite_calcul/src/main/java/beans/Addition.java @@ -0,0 +1,113 @@ +package beans; + +import java.awt.BorderLayout; +import java.awt.Color; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/** + * + * @author stag + */ +public class Addition extends JPanel { + + private final JPanel place, operation, answer, button; + private final JTextField proposition; + + + public Addition() { + place = new JPanel(); + operation = new JPanel(); + answer = new JPanel(); + button = new JPanel(); + + + + // génération d'un double >= 0.0 et < 1.0 + double n1 = Math.random(); + double n2 = Math.random(); + + // La conversion en entier va malheureusement retrancher les chiffres + // après le point et la valeur obtenue sera 0. + int c1 = (int) n1; + int c2 = (int) n2; + + // Pour obtenir une valeur entière non nulle, il faut multiplier le + // nombre aléatoire avec un nombre supérieur 0 avant la conversion. + // Par exemple, la multiplication par 9 donnera au final un nombre + // entier égal à 0, 1, 2, 3 --> 9. + // génération d'un entier >= 0 et <= 9 + c1 = (int) (Math.random() * 10); + c2 = (int) (Math.random() * 10); + + String strC1 = String.valueOf(c1); + String strC2 = String.valueOf(c2); + + JLabel addition = new JLabel(strC1 + " + " + strC2); + + operation.add(addition); + + + //partie answer + int resultatA = c1 + c2; + + String resultAdd = String.valueOf(resultatA); + + JLabel resultA = new JLabel(resultAdd); + JLabel propo = new JLabel("Entre ta réponse: "); + if (propo != resultA) { + System.out.println("Retente ta chance"); + } + + proposition = new JTextField(2); + + JButton check = new JButton("Vérifie"); + check.setBackground(Color.green); + JButton solution = new JButton("Solution"); + solution.setBackground(Color.red); + JButton other = new JButton("Autre calcul"); + other.setBackground(Color.lightGray); + + button.add(check); + button.add(solution); + button.add(other); + + answer.add(propo); + answer.add(proposition); + + + + createGUI(); + + } + + private void createGUI() { +// this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + +// JButton check = new JButton("Vérifie"); +// JButton solution = new JButton("Solution"); +// JButton other = new JButton("Autre calcul"); +// +// addGroup.add(check); +// addGroup.add(solution); +// addGroup.add(other); + + place.setLayout(new BorderLayout()); + + place.add(operation, BorderLayout.WEST); + place.add(answer, BorderLayout.EAST); + place.add(button, BorderLayout.SOUTH); + +// operation.setLayout(new FlowLayout(FlowLayout.LEFT)); +// answer.setLayout(new FlowLayout(FlowLayout.RIGHT)); +// button.setLayout(new FlowLayout()); + + + this.add(operation); + this.add(answer); + this.add(button); + + } +} diff --git a/02_Calcul/Activite_calcul/src/main/java/beans/Substraction.java b/02_Calcul/Activite_calcul/src/main/java/beans/Substraction.java new file mode 100644 index 0000000000000000000000000000000000000000..627d1b88c8dcaa2c3530cdf9da7faf489ac9e86f --- /dev/null +++ b/02_Calcul/Activite_calcul/src/main/java/beans/Substraction.java @@ -0,0 +1,118 @@ +package beans; + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/** + * + * @author cedric + */ +public class Substraction extends JPanel { + + private final JPanel operation, answer, button; + private final JTextField proposition; + + + public Substraction() { + + operation = new JPanel(); + answer = new JPanel(); + button = new JPanel(); + + // génération d'un double >= 0.0 et < 1.0 + double n1 = Math.random(); + double n2 = Math.random(); + + // La conversion en entier va malheureusement retrancher les chiffres + // après le point et la valeur obtenue sera 0. + int c1 = (int) n1; + int c2 = (int) n2; + + // Pour obtenir une valeur entière non nulle, il faut multiplier le + // nombre aléatoire avec un nombre supérieur 0 avant la conversion. + // Par exemple, la multiplication par 9 donnera au final un nombre + // entier égal à 0, 1, 2, 3 --> 9. + // génération d'un entier >= 0 et <= 9 + c1 = (int) (Math.random() * 10); + c2 = (int) (Math.random() * 10); + + do { + c1 = (int) (Math.random() * 10); + } while (c1 < c2); + + String strC1 = String.valueOf(c1); + String strC2 = String.valueOf(c2); + + JLabel substraction = new JLabel(strC1 + " - " + strC2); + + operation.add(substraction); + + //partie answer + int resultatS = c1 - c2; + + String resultSub = String.valueOf(resultatS); + + JLabel resultS = new JLabel(resultSub); + JLabel propo = new JLabel("Entre ta réponse: "); + + proposition = new JTextField(2); + + JButton check = new JButton("Vérifier"); + check.setBackground(Color.green); + check.addActionListener((ActionEvent e) -> { + int userResponse = Integer.parseInt(proposition.getText()); + if (userResponse == resultatS) { + JOptionPane.showMessageDialog(proposition, "Félicitation"); + } else { + JOptionPane.showMessageDialog(proposition, "Retente ta chance"); + } + }); + + JButton solution = new JButton("Solution"); + solution.setBackground(Color.red); + solution.addActionListener((ActionEvent e) -> { + JOptionPane.showMessageDialog(proposition, "le résultat est " + resultatS); + }); + + JButton other = new JButton("Autre calcul"); + other.setBackground(Color.lightGray); + other.addActionListener((ActionEvent e) -> { +// JOptionPane.showMessageDialog(proposition, resultS, strC2, resultatS, icon); +// ) + + }); + + + button.add(check); + button.add(solution); + button.add(other); + + answer.add(propo); + answer.add(proposition); + + createGUI(); + + } + + private void createGUI() { + this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + + operation.setLayout(new FlowLayout(FlowLayout.LEFT)); + answer.setLayout(new FlowLayout(FlowLayout.RIGHT)); + button.setLayout(new FlowLayout()); + + this.add(operation); + this.add(answer); + this.add(button); + + + } + +} diff --git a/02_Calcul/Activite_calcul/target/classes/Calcul/Main.class b/02_Calcul/Activite_calcul/target/classes/Calcul/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..40a43920343e8d7356961e7e37762c6d38aa8da1 Binary files /dev/null and b/02_Calcul/Activite_calcul/target/classes/Calcul/Main.class differ diff --git a/02_Calcul/Activite_calcul/target/classes/Calcul/TestCalcul.class b/02_Calcul/Activite_calcul/target/classes/Calcul/TestCalcul.class new file mode 100644 index 0000000000000000000000000000000000000000..0d585fa31f9263e64502c2296f3a0650ede6f2a9 Binary files /dev/null and b/02_Calcul/Activite_calcul/target/classes/Calcul/TestCalcul.class differ diff --git a/02_Calcul/Activite_calcul/target/classes/beans/Addition.class b/02_Calcul/Activite_calcul/target/classes/beans/Addition.class new file mode 100644 index 0000000000000000000000000000000000000000..6a8bb9e4cf67d7b7d08bf68929e819c1a9bc9d7a Binary files /dev/null and b/02_Calcul/Activite_calcul/target/classes/beans/Addition.class differ diff --git a/02_Calcul/Activite_calcul/target/classes/beans/Substraction.class b/02_Calcul/Activite_calcul/target/classes/beans/Substraction.class new file mode 100644 index 0000000000000000000000000000000000000000..f0e602c366773d1f12ab8f96dfb416532eb9732d Binary files /dev/null and b/02_Calcul/Activite_calcul/target/classes/beans/Substraction.class differ diff --git a/02_Calcul/Activite_calcul/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/02_Calcul/Activite_calcul/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..9c60d4097c87b6494d5133e167ecf0829f0bda84 --- /dev/null +++ b/02_Calcul/Activite_calcul/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,4 @@ +beans/Substraction.class +Calcul/Main.class +Calcul/TestCalcul.class +beans/Addition.class diff --git a/02_Calcul/Activite_calcul/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/02_Calcul/Activite_calcul/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..f66af9686ffa6c91cc0fc1cf2fab8739022c469d --- /dev/null +++ b/02_Calcul/Activite_calcul/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +/home/stag/Documents/JSE/Exos/projet_Activités/projet_groupe05/02_Calcul/Activite_calcul/src/main/java/beans/Addition.java +/home/stag/Documents/JSE/Exos/projet_Activités/projet_groupe05/02_Calcul/Activite_calcul/src/main/java/beans/Substraction.java +/home/stag/Documents/JSE/Exos/projet_Activités/projet_groupe05/02_Calcul/Activite_calcul/src/main/java/Calcul/Main.java +/home/stag/Documents/JSE/Exos/projet_Activités/projet_groupe05/02_Calcul/Activite_calcul/src/main/java/Calcul/TestCalcul.java diff --git a/02_Calcul/Documents/CDC.odt b/02_Calcul/Documents/CDC.odt new file mode 100644 index 0000000000000000000000000000000000000000..08269fd1d06487c69488462a99d189b7b5fcba4f Binary files /dev/null and b/02_Calcul/Documents/CDC.odt differ diff --git a/02_Calcul/Documents/exemple_visu01.odt b/02_Calcul/Documents/exemple_visu01.odt new file mode 100644 index 0000000000000000000000000000000000000000..942e4f80714125eea4dc8235d67da1c7e139d173 Binary files /dev/null and b/02_Calcul/Documents/exemple_visu01.odt differ diff --git a/02_Calcul/Documents/note_Panel b/02_Calcul/Documents/note_Panel new file mode 100644 index 0000000000000000000000000000000000000000..54df248be245e8d4a5cc4902fc46c7461f372bbe --- /dev/null +++ b/02_Calcul/Documents/note_Panel @@ -0,0 +1,41 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package Calcul; + + +import beans.Operation; +import javax.swing.Box; +import javax.swing.JPanel; + +/** + * Activite + * + * @author cedric + */ +public class Activite_calcul extends JPanel { + + private final Box content; + + private final Operation calPanel; + + public Activite_calcul() { + this.content = Box.createVerticalBox(); + + this.calPanel = new Operation(); + + this.initGui(); + + this.setSize(500, 500); + + } + + private void initGui() { + this.content.add(calPanel); + this.add(content); + + + } +} + diff --git a/02_Calcul/Documents/notes _pour_calcul.odt b/02_Calcul/Documents/notes _pour_calcul.odt new file mode 100644 index 0000000000000000000000000000000000000000..9cc8e80a9dcd9ae81b14c21b05d6d194fd3403f4 Binary files /dev/null and b/02_Calcul/Documents/notes _pour_calcul.odt differ diff --git a/02_Calcul/exemple_visu01.odt b/02_Calcul/exemple_visu01.odt new file mode 100644 index 0000000000000000000000000000000000000000..492ec4738ce762a8817a155f4b1aec2fe5bd83d3 Binary files /dev/null and b/02_Calcul/exemple_visu01.odt differ