wow le tp là

This commit is contained in:
Simoes Lukas
2025-09-04 15:36:55 +02:00
parent c16ef0985f
commit 2c3e150ec5
87 changed files with 1059 additions and 28 deletions
View File
+5
View File
@@ -0,0 +1,5 @@
t = [5,8,8,7,5,8,3,5,7,8,4,4,4,5,3,1,2,3,7]
t.sort()
print(t)
Binary file not shown.
+8 -8
View File
@@ -1,15 +1,15 @@
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
String[] sujets = { String[] sujets = {
"Luc", "Siobhane",
"Denis", "Lukas",
"Régine", "Maxime",
"Selma", "Nima",
"Frédéric" "Mehdi"
}; };
String[] verbes = { String[] verbes = {
"aime", "mord",
"déteste", "déteste",
"tue", "tue",
"mange", "mange",
@@ -17,10 +17,10 @@ public class Main {
}; };
String[] complements = { String[] complements = {
"Windows", "Sasha",
"les pommes", "les pommes",
"Elizabeth II", "Elizabeth II",
"les batyscaphes" // Je sais même pas si c'est un nom commun en vrai "le capitalisme" // Je sais même pas si c'est un nom commun en vrai
}; };
Exquis sujet = new Exquis(sujets); Exquis sujet = new Exquis(sujets);
+19
View File
@@ -0,0 +1,19 @@
import java.awt.*;
import javax.swing.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
public class Menu extends JFrame{
public Menu() {
this.setSize(800, 1000);
this.setLocation(500, 0);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
FondMenuPrincipale menu = new FondMenuPrincipale();
this.add(menu);
this.addMouseListener(new Quitter());
this.addMouseListener(new BoutonJouer(this));
}
}
Submodule DEV2.1/SAE21_2025 updated: b9598b5ae3...9a2f651524
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -7,7 +7,7 @@ public class Fond {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
try { try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); UIManager.setLookAndFeel("javax.swing.plaf.nimbus");
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
} }
} catch (InstantiationException e2) { } catch (InstantiationException e2) {
Binary file not shown.
+26 -10
View File
@@ -5,17 +5,21 @@ public class Composant extends JComponent {
private Color couleur1; private Color couleur1;
private Color couleur2; private Color couleur2;
private JLabel nomCouleur1; private String nomCouleur1;
private JLabel nomCouleur2; private String nomCouleur2;
public Composant(Color couleur1, Color couleur2) { public Composant(Color couleur1, Color couleur2, String nomCouleur1, String nomCouleur2) {
this.couleur1 = couleur1; this.couleur1 = couleur1;
this.couleur2 = couleur2; this.couleur2 = couleur2;
this.nomCouleur1 = nomCouleur1;
this.nomCouleur2 = nomCouleur2;
} }
@Override @Override
public void paintComponent(Graphics pinceau) { public void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create(); Graphics secondPinceau = pinceau.create();
FontMetrics metrique = pinceau.getFontMetrics();
int tailleTexte1 = metrique.stringWidth(this.nomCouleur2);
int[] x1 = {0, 0, this.getWidth()}; int[] x1 = {0, 0, this.getWidth()};
int[] y1 = {0, this.getHeight(), this.getHeight()}; int[] y1 = {0, this.getHeight(), this.getHeight()};
@@ -28,14 +32,26 @@ public class Composant extends JComponent {
secondPinceau.setColor(this.couleur2); secondPinceau.setColor(this.couleur2);
secondPinceau.fillPolygon(x2, y2, 3); secondPinceau.fillPolygon(x2, y2, 3);
JLabel couleur1Nom = this.nomCouleur1; secondPinceau.setColor(this.couleur1);
JLabel couleur2Nom = this.nomCouleur2; secondPinceau.drawString(this.nomCouleur2, this.getWidth() - tailleTexte1 - 10, metrique.getAscent() + 10);
secondPinceau.setColor(this.couleur2);
secondPinceau.drawString(this.nomCouleur1, 10, this.getHeight() - 10);
couleur1Nom.setHorizontalAlignment(JLabel.RIGHT); }
couleur2Nom.setHorizontalAlignment(JLabel.LEFT);
this.setLayout(new BorderLayout()); public void setCouleur1(Color couleur) {
this.add(couleur1Nom, BorderLayout.NORTH); this.couleur1 = couleur;
this.add(couleur2Nom, BorderLayout.SOUTH); }
public void setCouleur2(Color couleur) {
this.couleur2 = couleur;
}
public void setNomCouleur1(String couleur) {
this.nomCouleur1 = couleur;
}
public void setNomCouleur2(String couleur) {
this.nomCouleur2 = couleur;
} }
} }
Binary file not shown.
+10 -4
View File
@@ -7,9 +7,15 @@ public class Fenetre extends JFrame {
this.setSize(200, 200); this.setSize(200, 200);
this.setLocation(100, 100); this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(1, 1)); this.setLayout(new BorderLayout());
Color couleur1 = // TODO LectureFichier fichier = new LectureFichier();
Color couleur2 = // TODO Color couleur1 = fichier.getCouleurs()[64];
this.add(new Composant(couleur1, couleur2)); Color couleur2 = fichier.getCouleurs()[16];
String nom1 = fichier.getNomsCouleurs()[64];
String nom2 = fichier.getNomsCouleurs()[16];
Composant composant = new Composant(couleur1, couleur2, nom1, nom2);
this.add(composant, BorderLayout.CENTER);
this.addMouseWheelListener(new GestionMoletteSouris(composant, fichier.getCouleurs(), fichier.getNomsCouleurs()));
} }
} }
Binary file not shown.
@@ -0,0 +1,55 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GestionMoletteSouris implements MouseWheelListener {
private Composant composant;
private Color[] tabCouleurs ;
private String[] tabNomsCouleurs;
private int positionTabCouleurs1;
private int positionTabCouleurs2;
public GestionMoletteSouris(Composant composant, Color[] tabCouleurs, String[] tabNomsCouleurs) {
this.composant = composant;
this.tabCouleurs = tabCouleurs;
this.tabNomsCouleurs = tabNomsCouleurs;
this.positionTabCouleurs1 = 64;
this.positionTabCouleurs2 = 16;
}
public void mouseWheelMoved(MouseWheelEvent evenement) {
int posX = evenement.getX();
int posY = evenement.getY();
if (posX < posY) {
if (evenement.getWheelRotation() < 0) {
this.positionTabCouleurs1++;
this.positionTabCouleurs1 = this.positionTabCouleurs1 % this.tabCouleurs.length;
this.composant.setCouleur1(this.tabCouleurs[this.positionTabCouleurs1]);
this.composant.setNomCouleur1(this.tabNomsCouleurs[this.positionTabCouleurs1]);
}
else {
this.positionTabCouleurs1--;
this.positionTabCouleurs1 = this.positionTabCouleurs1 % this.tabCouleurs.length;
this.composant.setCouleur1(this.tabCouleurs[this.positionTabCouleurs1]);
this.composant.setNomCouleur1(this.tabNomsCouleurs[this.positionTabCouleurs1]);
}
}
else {
if (evenement.getWheelRotation() < 0) {
this.positionTabCouleurs2++;
this.positionTabCouleurs2 = this.positionTabCouleurs2 % this.tabCouleurs.length;
this.composant.setCouleur2(this.tabCouleurs[this.positionTabCouleurs2]);
this.composant.setNomCouleur2(this.tabNomsCouleurs[this.positionTabCouleurs2]);
}
else {
this.positionTabCouleurs2--;
this.positionTabCouleurs2 = this.positionTabCouleurs2 % this.tabCouleurs.length;
this.composant.setCouleur2(this.tabCouleurs[this.positionTabCouleurs2]);
this.composant.setNomCouleur2(this.tabNomsCouleurs[this.positionTabCouleurs2]);
}
}
System.out.println(positionTabCouleurs1 + " / " + positionTabCouleurs2);
this.composant.repaint();
}
}
Binary file not shown.
+22 -2
View File
@@ -1,5 +1,6 @@
import java.awt.*; import java.awt.*;
import java.io.*; import java.io.*;
import java.util.Arrays;
public class LectureFichier { public class LectureFichier {
@@ -7,13 +8,24 @@ public class LectureFichier {
private String[] tabNomsCouleurs; private String[] tabNomsCouleurs;
public LectureFichier() { public LectureFichier() {
this.tabCouleurs = new Color[800];
this.tabNomsCouleurs = new String[800];
try { try {
BufferedReader lecture = new BufferedReader(new FileReader("rgb.txt")); BufferedReader lecture = new BufferedReader(new FileReader("rgb.txt"));
try { try {
String ligne = lecture.readLine(); String ligne = lecture.readLine();
// TODO : Split, trim des lignes + Gestion Molette int compteur = 0;
while (ligne != null) {
int r = Integer.parseInt(ligne.substring(0, 3).replaceAll(" ", "0"));
int g = Integer.parseInt(ligne.substring(4, 7).replaceAll(" ", "0"));
int b = Integer.parseInt(ligne.substring(8, 11).replaceAll(" ", "0"));
this.tabCouleurs[compteur] = new Color(r, g, b);
ligne = ligne.substring(11, ligne.length()).replaceAll(" ", "");
this.tabNomsCouleurs[compteur] = ligne;
ligne = lecture.readLine();
compteur++;
}
} catch (IOException e2) { } catch (IOException e2) {
System.err.println("Erreur de lecture."); System.err.println("Erreur de lecture.");
} }
@@ -27,4 +39,12 @@ public class LectureFichier {
} }
} }
public Color[] getCouleurs() {
return this.tabCouleurs;
}
public String[] getNomsCouleurs() {
return this.tabNomsCouleurs;
}
} }
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
+36
View File
@@ -0,0 +1,36 @@
import java.awt.*;
import java.io.*;
public class Prototype {
public static void main(String[] args) {
if (args.length < 1) {
System.err.println("Veuillez entrer un nom dans la ligne de commande.");
}
else {
try {
BufferedWriter flux = new BufferedWriter(new FileWriter(args[0] + ".java"));
try {
flux.write("public class " + args[0] + " {");
flux.newLine();
flux.write(" public static void main(String[] args) {");
flux.newLine();
flux.write(" System.out.println(\"Bonjour, je m'appelle " + args[0] + ".java\");");
flux.newLine();
flux.write(" }");
flux.newLine();
flux.write("}");
} catch (IOException e2) {
System.err.println("Erreur d'écriture du fichier");
}
try {
flux.close();
} catch (IOException e3) {
System.err.println("Erreur de fermeture du fichier");
}
} catch (IOException e1){
System.err.println("Erreur de création/d'ouverture de fichier");
}
}
}
}
Binary file not shown.
+5
View File
@@ -0,0 +1,5 @@
public class Test {
public static void main(String[] args) {
System.out.println("Bonjour, je m'appelle Test.java");
}
}
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
public class Main {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Entrez une valeur dans la console.");
System.exit(0);
}
Vote v = new Vote(args[0]);
}
}
Binary file not shown.
+52
View File
@@ -0,0 +1,52 @@
import org.mariadb.jdbc.*;
import java.awt.*;
import java.sql.*;
public class Vote {
private String competiteur;
public Vote(String competiteur) {
this.competiteur = competiteur;
try {
Connection cnx = DriverManager.getConnection(
"jdbc:mariadb://dwarves.iut-fbleau.fr/simoes",
"simoes", "simoes"
);
try {
Class.forName("org.mariadb.jdbc.Driver");
} catch (ClassNotFoundException e2) {
System.err.println("Problème de pilote.");
}
try {
PreparedStatement pst = cnx.prepareStatement(
"SELECT votants, points FROM pays WHERE competiteur = '" + this.competiteur + "';"
);
ResultSet rs = pst.executeQuery();
int total = 0;
while (rs.next()) {
total += rs.getInt(2);
System.out.println(rs.getString(1) + " " + rs.getInt(2));
}
System.out.println("---------");
System.out.println("Total " + total);
rs.close();
pst.close();
} catch (SQLException e3) {
System.err.println("Erreur de syntaxe SQL.");
}
cnx.close();
} catch (SQLException e1) {
System.err.println("Erreur de connexion à la base de données.");
}
}
}
Binary file not shown.
+56
View File
@@ -0,0 +1,56 @@
import org.mariadb.jdbc.*;
import javax.swing.*;
import java.sql.*;
public class Connexion {
private int scoreMax;
private String paysMax;
public Connexion() {
try {
Connection cnx = DriverManager.getConnection(
"jdbc:mariadb://dwarves.iut-fbleau.fr/simoes",
"simoes", "simoes"
);
try {
Class.forName("org.mariadb.jdbc.Driver");
} catch (ClassNotFoundException e2) {
System.err.println("Problème de pilote.");
}
try {
PreparedStatement pst = cnx.prepareStatement(
"SELECT SUM(points), competiteur FROM pays GROUP BY competiteur ASC;"
);
ResultSet rs = pst.executeQuery();
int total = 0;
rs.next();
this.scoreMax = rs.getInt(1);
this.paysMax = rs.getString(2);
rs.close();
pst.close();
} catch (SQLException e3) {
System.err.println("Erreur de syntaxe SQL.");
}
cnx.close();
} catch (SQLException e1) {
System.err.println("Erreur de connexion à la base de données.");
}
}
public String getNomPays() {
return this.paysMax;
}
public int getScorePays() {
return this.scoreMax;
}
}
Binary file not shown.
+43
View File
@@ -0,0 +1,43 @@
import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
private String nomPays;
private int scorePays;
public Fenetre(String nomPays, int scorePays) {
this.nomPays = nomPays;
this.scorePays = scorePays;
this.setSize(200, 200);
this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new BorderLayout());
JLabel pays = new JLabel(this.nomPays);
JLabel score = new JLabel(this.scorePays + "");
JPanel south = new JPanel();
JButton refresh = new JButton("");
refresh.addActionListener(new Rafraichir(score, pays, this));
Font policeScore = new Font("Arial", Font.BOLD, 60);
Font policePays = new Font("Arial", Font.BOLD, 40);
score.setFont(policeScore);
pays.setFont(policePays);
pays.setHorizontalAlignment(JLabel.CENTER);
score.setHorizontalAlignment(JLabel.CENTER);
refresh.setHorizontalAlignment(JButton.RIGHT);
this.add(pays, BorderLayout.NORTH);
this.add(score, BorderLayout.CENTER);
this.add(south, BorderLayout.SOUTH);
south.setLayout(new BorderLayout());
south.add(refresh, BorderLayout.EAST);
}
}
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
public class Main {
public static void main(String[] args) {
Connexion cnx = new Connexion();
Fenetre fenetre = new Fenetre(cnx.getNomPays(), cnx.getScorePays());
fenetre.setVisible(true);
}
}
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Rafraichir implements ActionListener {
private JLabel texteScore;
private JLabel textePays;
private Fenetre fenetre;
public Rafraichir(JLabel texteScore, JLabel textePays, Fenetre fenetre) {
this.texteScore = texteScore;
this.textePays = textePays;
this.fenetre = fenetre;
}
public void actionPerformed(ActionEvent evenement) {
Connexion cnx2 = new Connexion();
this.texteScore.setText(cnx2.getScorePays() + "");
this.textePays.setText(cnx2.getNomPays());
this.fenetre.repaint();
}
}
Binary file not shown.
@@ -0,0 +1,52 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
public class Controlleur implements MouseListener {
private JLabel img;
private Fenetre fenetre;
private String[] images;
private int actuel;
public Controlleur(JLabel img, Fenetre fenetre) {
this.img = img;
this.fenetre = fenetre;
String[] temp = {
"img1.jpg",
"img2.jpg",
"img3.jpg",
"img4.jpg"
};
this.images = temp;
this.actuel = 0;
}
public void mouseClicked(MouseEvent evenement) {
if (evenement.getX() < this.fenetre.getWidth()/2) {
this.actuel--;
if (this.actuel == -1) {
this.actuel = 3;
}
}
else {
this.actuel++;
if (this.actuel == 4) {
this.actuel = 0;
}
}
this.fenetre.getContentPane().removeAll();
this.fenetre.add(new JLabel(new ImageIcon(this.images[this.actuel])));
this.fenetre.revalidate();
this.fenetre.repaint();
} // un bouton cliqué
public void mouseEntered(MouseEvent evenement) {} // debut du survol
public void mouseExited(MouseEvent evenement) {} // fin du survol
public void mousePressed(MouseEvent evenement) {} // un bouton appuyé
public void mouseReleased(MouseEvent evenement) {} // un bouton relâché
}
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
public Fenetre() {
this.setSize(900, 450);
this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(1, 1));
JLabel img = new JLabel(new ImageIcon("img1.jpg"));
this.add(img);
this.addMouseListener(new Controlleur(img, this));
}
}
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Some files were not shown because too many files have changed in this diff Show More