diff --git a/DEV2.1/SAE21_2025 b/DEV2.1/SAE21_2025 new file mode 160000 index 0000000..c546240 --- /dev/null +++ b/DEV2.1/SAE21_2025 @@ -0,0 +1 @@ +Subproject commit c5462401edb1a4b551292c62563745d06f71de07 diff --git a/DEV2.1/Sudoku/Case.class b/DEV2.1/Sudoku/Case.class new file mode 100644 index 0000000..0e21723 Binary files /dev/null and b/DEV2.1/Sudoku/Case.class differ diff --git a/DEV2.1/Sudoku/Case.java b/DEV2.1/Sudoku/Case.java new file mode 100644 index 0000000..e07c7a6 --- /dev/null +++ b/DEV2.1/Sudoku/Case.java @@ -0,0 +1,26 @@ +import java.awt.*; +import javax.swing.*; + +public class Case extends JComponent { + + @Override + public void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + + if (this.isOpaque()) { + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + secondPinceau.setColor(Color.BLACK); + secondPinceau.drawRect(0, 0, this.getWidth()-3, this.getHeight()-3); + secondPinceau.drawRect(1, 1, this.getWidth()-4, this.getHeight()-4); + secondPinceau.drawRect(2, 2, this.getWidth()-5, this.getHeight()-5); + + for (int i = 0; i != 3; i++) { + for (int j = 0; j != 3; j++) { + secondPinceau.drawRect(this.getWidth()*i/3, this.getHeight()*j/3, this.getWidth()/3, this.getHeight()/3); + } + } + } +} \ No newline at end of file diff --git a/DEV2.1/Sudoku/Graphique.class b/DEV2.1/Sudoku/Graphique.class new file mode 100644 index 0000000..e5add32 Binary files /dev/null and b/DEV2.1/Sudoku/Graphique.class differ diff --git a/DEV2.1/Sudoku/Graphique.java b/DEV2.1/Sudoku/Graphique.java new file mode 100644 index 0000000..836d5d6 --- /dev/null +++ b/DEV2.1/Sudoku/Graphique.java @@ -0,0 +1,17 @@ +import java.awt.*; +import javax.swing.*; + +public class Graphique extends JFrame { + + public Graphique() { + this.setSize(600, 600); + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + this.setLayout(new GridLayout(9, 9)); + + for (int i = 0; i != 81; i++) { + this.add(new JTextField()); + } + } +} \ No newline at end of file diff --git a/DEV2.1/Sudoku/Main.class b/DEV2.1/Sudoku/Main.class new file mode 100644 index 0000000..e67db45 Binary files /dev/null and b/DEV2.1/Sudoku/Main.class differ diff --git a/DEV2.1/Sudoku/Main.java b/DEV2.1/Sudoku/Main.java new file mode 100644 index 0000000..b1d9f7d --- /dev/null +++ b/DEV2.1/Sudoku/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + Graphique fenetre = new Graphique(); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TDs/Fenetre.class b/DEV2.1/TDs/Fenetre.class new file mode 100644 index 0000000..ec570e7 Binary files /dev/null and b/DEV2.1/TDs/Fenetre.class differ diff --git a/DEV2.1/TDs/Fenetre.java b/DEV2.1/TDs/Fenetre.java new file mode 100644 index 0000000..e69de29 diff --git a/DEV2.1/TDs/Img.class b/DEV2.1/TDs/Img.class new file mode 100644 index 0000000..fe69a1e Binary files /dev/null and b/DEV2.1/TDs/Img.class differ diff --git a/DEV2.1/TDs/Img.java b/DEV2.1/TDs/Img.java new file mode 100644 index 0000000..2246c68 --- /dev/null +++ b/DEV2.1/TDs/Img.java @@ -0,0 +1,43 @@ +import java.awt.*; +import javax.swing.*; + +public class Img extends JComponent { + private Image img; + + public Img() { + // Chargement de l'image + img = new ImageIcon("fond.png").getImage(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + if (img != null) { + g.drawImage(img, 0, 0, this); + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(500, 500); // Ajustez à la taille de l'image + } +} + +class Fenetre extends JFrame { + public Fenetre() { + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + Img imagePanel = new Img(); + this.add(imagePanel); + + this.pack(); // Ajuste la fenêtre à la taille du contenu + this.setVisible(true); + } +} + +public class Main { + public static void main(String[] args) { + SwingUtilities.invokeLater(Fenetre::new); + } +} \ No newline at end of file diff --git a/DEV2.1/TDs/Main.class b/DEV2.1/TDs/Main.class new file mode 100644 index 0000000..bfb4d24 Binary files /dev/null and b/DEV2.1/TDs/Main.class differ diff --git a/DEV2.1/TDs/Main.java b/DEV2.1/TDs/Main.java new file mode 100644 index 0000000..8567b63 --- /dev/null +++ b/DEV2.1/TDs/Main.java @@ -0,0 +1,39 @@ +import java.awt.*; +import javax.swing.*; + +class Img extends JComponent { + private Image img; + + public Img() { + // Chargement de l'image + img = Toolkit.getDefaultToolkit().getImage("triangles-1430105_1280.png"); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + if (img != null) { + g.drawImage(img, 0, 0, this); + } + } + +} + +class Fenetre extends JFrame { + public Fenetre() { + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + Img imagePanel = new Img(); + this.add(imagePanel); + + this.pack(); // Ajuste la fenêtre à la taille du contenu + } +} + +public class Main { + public static void main(String[] args) { + Fenetre fenetre = new Fenetre(); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TDs/Reels.class b/DEV2.1/TDs/Reels.class new file mode 100644 index 0000000..9531b45 Binary files /dev/null and b/DEV2.1/TDs/Reels.class differ diff --git a/DEV2.1/TDs/Reels.java b/DEV2.1/TDs/Reels.java new file mode 100644 index 0000000..da979fb --- /dev/null +++ b/DEV2.1/TDs/Reels.java @@ -0,0 +1,35 @@ +import java.awt.*; +import java.io.*; + +public class Reels { + public static void main(String[] args) { + try { + FileWriter fichier = new FileWriter("reels.txt"); + BufferedWriter flux = new BufferedWriter(fichier); + + try { + flux.write("12.8391319"); + flux.newLine(); + flux.write("45.72"); + flux.newLine(); + flux.write("12.283939273718317174"); + flux.newLine(); + flux.write("1.0"); + flux.newLine(); + + } catch (IOException e2 ) { + System.out.println("Erreur d'écriture"); + } + + try { + flux.close(); + } catch (IOException e3) { + + System.out.println("Erreur de femreture"); + } + } catch (IOException e) { + System.out.println("Erreur d'ouverture"); + } + } + +} \ No newline at end of file diff --git a/DEV2.1/TDs/Somme.class b/DEV2.1/TDs/Somme.class new file mode 100644 index 0000000..da4adfd Binary files /dev/null and b/DEV2.1/TDs/Somme.class differ diff --git a/DEV2.1/TDs/Somme.java b/DEV2.1/TDs/Somme.java new file mode 100644 index 0000000..1941589 --- /dev/null +++ b/DEV2.1/TDs/Somme.java @@ -0,0 +1,9 @@ +import java.awt.*; +import java.io.*; + +public class Somme { + public static void main(String[] args) { + InputStreamReader lecture = new InputStreamReader(System.in); + BufferedReader flux = new BufferedReader(lecture); + } +} \ No newline at end of file diff --git a/DEV2.1/TDs/fond.png b/DEV2.1/TDs/fond.png new file mode 100644 index 0000000..0a17438 Binary files /dev/null and b/DEV2.1/TDs/fond.png differ diff --git a/DEV2.1/TDs/reels.bin b/DEV2.1/TDs/reels.bin index 4e2a699..57c0016 100644 Binary files a/DEV2.1/TDs/reels.bin and b/DEV2.1/TDs/reels.bin differ diff --git a/DEV2.1/TDs/reels.txt b/DEV2.1/TDs/reels.txt new file mode 100644 index 0000000..57c0016 --- /dev/null +++ b/DEV2.1/TDs/reels.txt @@ -0,0 +1,4 @@ +12.8391319 +45.72 +12.283939273718317174 +1.0 diff --git a/DEV2.1/TDs/triangles-1430105_1280.png b/DEV2.1/TDs/triangles-1430105_1280.png new file mode 100644 index 0000000..f6a040a Binary files /dev/null and b/DEV2.1/TDs/triangles-1430105_1280.png differ diff --git a/DEV2.1/TDs/triangles-1430105_1280.webp b/DEV2.1/TDs/triangles-1430105_1280.webp new file mode 100644 index 0000000..0a17438 Binary files /dev/null and b/DEV2.1/TDs/triangles-1430105_1280.webp differ diff --git a/DEV2.1/TP05/Nuance.java b/DEV2.1/TP05/Nuance.java index 40e8377..48ef7ce 100644 --- a/DEV2.1/TP05/Nuance.java +++ b/DEV2.1/TP05/Nuance.java @@ -36,9 +36,9 @@ public class Nuance extends JPanel { for (String element : args) { element = element.replaceAll("#", ""); int[] couleurs = { - Integer.parseInt(element.substring(0,2), 16), - Integer.parseInt(element.substring(2,4), 16), - Integer.parseInt(element.substring(4,6), 16) + Integer.parseInt(element.substring(5,7), 16), + Integer.parseInt(element.substring(7,9), 16), + Integer.parseInt(element.substring(9,11), 16) }; fenetre.add(new Nuance(couleurs)); } diff --git a/DEV2.1/TP10/05_Degres/Conversion.class b/DEV2.1/TP10/05_Degres/Conversion.class deleted file mode 100644 index 5fa4609..0000000 Binary files a/DEV2.1/TP10/05_Degres/Conversion.class and /dev/null differ diff --git a/DEV2.1/TP10/05_Degres/Conversion.java b/DEV2.1/TP10/05_Degres/Conversion.java index c50f39e..b6a45db 100644 --- a/DEV2.1/TP10/05_Degres/Conversion.java +++ b/DEV2.1/TP10/05_Degres/Conversion.java @@ -1,9 +1,13 @@ public class Conversion { public static double celsiusAFahrenheit(double n) { + /** Prend en argument une température en degrés Celsius et + * renvoie sa valeur en degrés Fahrenheit **/ return n*9/5+32; } public static double FahrenheitACelsius(double n) { + /** Prend en argument une température en degrés Fahrenheit et + * renvoie sa valeur en degrés Celsius **/ return (n-32)*5/9; } } \ No newline at end of file diff --git a/DEV2.1/TP10/05_Degres/Degres.class b/DEV2.1/TP10/05_Degres/Degres.class deleted file mode 100644 index cd43692..0000000 Binary files a/DEV2.1/TP10/05_Degres/Degres.class and /dev/null differ diff --git a/DEV2.1/TP10/05_Degres/Fenetre.class b/DEV2.1/TP10/05_Degres/Fenetre.class deleted file mode 100644 index a6ddeeb..0000000 Binary files a/DEV2.1/TP10/05_Degres/Fenetre.class and /dev/null differ diff --git a/DEV2.1/TP10/05_Degres/GestionJTextField.class b/DEV2.1/TP10/05_Degres/GestionJTextField.class deleted file mode 100644 index 74ba1b2..0000000 Binary files a/DEV2.1/TP10/05_Degres/GestionJTextField.class and /dev/null differ diff --git a/DEV2.1/TP11/01_Image/LectureFichier.class b/DEV2.1/TP11/01_Image/LectureFichier.class index d44f9a3..d52942b 100644 Binary files a/DEV2.1/TP11/01_Image/LectureFichier.class and b/DEV2.1/TP11/01_Image/LectureFichier.class differ diff --git a/DEV2.1/TP11/01_Image/LectureFichier.java b/DEV2.1/TP11/01_Image/LectureFichier.java index 1c99c17..520ab8d 100644 --- a/DEV2.1/TP11/01_Image/LectureFichier.java +++ b/DEV2.1/TP11/01_Image/LectureFichier.java @@ -16,7 +16,7 @@ public class LectureFichier { Color couleur; try { - FileInputStream fichier = new FileInputStream("image.bin"); + FileInputStream fichier = new FileInputStream("couleur.bin"); while(fichier.available() >= 3) { try { diff --git a/DEV2.1/TP11/01_Image/couleur.bin b/DEV2.1/TP11/01_Image/couleur.bin index cf4d650..2d10628 100644 Binary files a/DEV2.1/TP11/01_Image/couleur.bin and b/DEV2.1/TP11/01_Image/couleur.bin differ diff --git a/DEV2.1/TP11/03_Coloriage/EcritureFichier.class b/DEV2.1/TP11/03_Coloriage/EcritureFichier.class index d46546b..fe059ec 100644 Binary files a/DEV2.1/TP11/03_Coloriage/EcritureFichier.class and b/DEV2.1/TP11/03_Coloriage/EcritureFichier.class differ diff --git a/DEV2.1/TP11/03_Coloriage/EcritureFichier.java b/DEV2.1/TP11/03_Coloriage/EcritureFichier.java index 4cdd895..64321fd 100644 --- a/DEV2.1/TP11/03_Coloriage/EcritureFichier.java +++ b/DEV2.1/TP11/03_Coloriage/EcritureFichier.java @@ -3,22 +3,22 @@ import java.io.*; public class EcritureFichier { - private byte r; - private byte g; - private byte b; + private int r; + private int g; + private int b; - private byte r2; - private byte g2; - private byte b2; + private int r2; + private int g2; + private int b2; - public EcritureFichier(byte r, byte g, byte b) { + public EcritureFichier(int r, int g, int b) { this.r = r; this.g = g; this.b = b; try { FileOutputStream fichier = new FileOutputStream("couleur.bin"); - + System.out.println(r + " " + g + " " + b); try { for (int i = 0; i != 768; i++) { for (int j = 0; j != 1024; j++) { @@ -42,7 +42,7 @@ public class EcritureFichier { } } - public EcritureFichier(byte r, byte g, byte b, byte r2, byte g2, byte b2) { + public EcritureFichier(int r, int g, int b, int r2, int g2, int b2) { this.r = r; this.g = g; this.b = b; @@ -52,15 +52,42 @@ public class EcritureFichier { try { FileOutputStream fichier = new FileOutputStream("couleur.bin"); + int choixR = r; + int choixG = g; + int choixB = b; try { - for (int i = 0; i != 768; i++) { - for (int j = 0; j != 1024; j++) { - fichier.write(r); - fichier.write(g); - fichier.write(b); + for (int l = 0; l != 8; l++) { + for (int k = 0; k != 8; k++) { + for (int i = 0; i != 768/8; i++) { + for (int j = 0; j != 1024/8; j++) { + fichier.write(choixR); + fichier.write(choixG); + fichier.write(choixB); + } + if (choixR == r) { + choixR = r2; + choixG = g2; + choixB = b2; + } + else { + choixR = r; + choixG = g; + choixB = b; + } + } } - } + if (choixR == r) { + choixR = r2; + choixG = g2; + choixB = b2; + } + else { + choixR = r; + choixG = g; + choixB = b; + } + } } catch (IOException e2) { System.out.println("Erreur d'écriture"); } diff --git a/DEV2.1/TP11/03_Coloriage/Main.class b/DEV2.1/TP11/03_Coloriage/Main.class index 3cf2a2c..645e0bf 100644 Binary files a/DEV2.1/TP11/03_Coloriage/Main.class and b/DEV2.1/TP11/03_Coloriage/Main.class differ diff --git a/DEV2.1/TP11/03_Coloriage/Main.java b/DEV2.1/TP11/03_Coloriage/Main.java index 3df0d59..ebf561d 100644 --- a/DEV2.1/TP11/03_Coloriage/Main.java +++ b/DEV2.1/TP11/03_Coloriage/Main.java @@ -1,11 +1,21 @@ public class Main { public static void main(String[] args) { + String chaineCouleur = args[0].replaceAll("#", ""); + Integer r = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(0, 2), 16)); + Integer g = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(2, 4), 16)); + Integer b = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(4, 6), 16)); + if (args.length == 1) { - String chaineCouleur = args[0].replaceAll("#", ""); - Integer r = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(0, 2), 16)); - Integer g = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(2, 4), 16)); - Integer b = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(4, 6), 16)); - EcritureFichier ecriture = new EcritureFichier(r.byteValue(), g.byteValue(), b.byteValue()); + EcritureFichier ecriture = new EcritureFichier(r, g, b); + } + + else if (args.length == 2) { + String chaineCouleur2 = args[1].replaceAll("#", ""); + Integer r2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(0, 2), 16)); + Integer g2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(2, 4), 16)); + Integer b2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(4, 6), 16)); + System.out.println(r + "," + g + "," + b + " | " + r2 + "," + g2 + "," + b2); + EcritureFichier ecriture2 = new EcritureFichier(r, g, b, r2, g2, b2); } } } \ No newline at end of file diff --git a/DEV2.1/TP11/03_Coloriage/couleur.bin b/DEV2.1/TP11/03_Coloriage/couleur.bin index cf4d650..2d10628 100644 Binary files a/DEV2.1/TP11/03_Coloriage/couleur.bin and b/DEV2.1/TP11/03_Coloriage/couleur.bin differ diff --git a/DEV2.1/TP11/04_Palette/EcritureFichier.java b/DEV2.1/TP11/04_Palette/EcritureFichier.java new file mode 100644 index 0000000..64321fd --- /dev/null +++ b/DEV2.1/TP11/04_Palette/EcritureFichier.java @@ -0,0 +1,108 @@ +import java.awt.*; +import java.io.*; + +public class EcritureFichier { + + private int r; + private int g; + private int b; + + private int r2; + private int g2; + private int b2; + + public EcritureFichier(int r, int g, int b) { + this.r = r; + this.g = g; + this.b = b; + + try { + FileOutputStream fichier = new FileOutputStream("couleur.bin"); + System.out.println(r + " " + g + " " + b); + try { + for (int i = 0; i != 768; i++) { + for (int j = 0; j != 1024; j++) { + fichier.write(r); + fichier.write(g); + fichier.write(b); + } + } + } catch (IOException e2) { + System.out.println("Erreur d'écriture"); + } + + try { + fichier.close(); + } catch (IOException e3) { + System.out.println("Erreur de fermeture"); + } + + } catch (IOException e) { + System.out.println("Erreur d'ouverture"); + } + } + + public EcritureFichier(int r, int g, int b, int r2, int g2, int b2) { + this.r = r; + this.g = g; + this.b = b; + this.r2 = r2; + this.g2 = g2; + this.b2 = b2; + + try { + FileOutputStream fichier = new FileOutputStream("couleur.bin"); + int choixR = r; + int choixG = g; + int choixB = b; + + try { + for (int l = 0; l != 8; l++) { + for (int k = 0; k != 8; k++) { + for (int i = 0; i != 768/8; i++) { + for (int j = 0; j != 1024/8; j++) { + fichier.write(choixR); + fichier.write(choixG); + fichier.write(choixB); + } + if (choixR == r) { + choixR = r2; + choixG = g2; + choixB = b2; + } + else { + choixR = r; + choixG = g; + choixB = b; + } + } + } + if (choixR == r) { + choixR = r2; + choixG = g2; + choixB = b2; + } + else { + choixR = r; + choixG = g; + choixB = b; + } + } + } catch (IOException e2) { + System.out.println("Erreur d'écriture"); + } + + try { + fichier.close(); + } catch (IOException e3) { + System.out.println("Erreur de fermeture"); + } + + } catch (IOException e) { + System.out.println("Erreur d'ouverture"); + } + + } + + +} \ No newline at end of file diff --git a/DEV2.1/TP11/04_Palette/Fenetre.java b/DEV2.1/TP11/04_Palette/Fenetre.java new file mode 100644 index 0000000..8b516e4 --- /dev/null +++ b/DEV2.1/TP11/04_Palette/Fenetre.java @@ -0,0 +1,12 @@ +import java.awt.*; +import javax.swing.*; + +public class Fenetre extends JFrame { + public Fenetre() { + this.setSize(768, 1024); + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLayout(new GridLayout(1, 1)); + this.add(new Image()); + } +} \ No newline at end of file diff --git a/DEV2.1/TP11/04_Palette/Image.java b/DEV2.1/TP11/04_Palette/Image.java new file mode 100644 index 0000000..0c09060 --- /dev/null +++ b/DEV2.1/TP11/04_Palette/Image.java @@ -0,0 +1,19 @@ +import java.awt.*; +import javax.swing.*; +import java.io.*; + +public class Image extends JComponent { + @Override + public void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + Color couleur; + + if (this.isOpaque()) { + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + secondPinceau.drawImage(new LectureFichier().getImage(), 0, 0, this); + + } +} \ No newline at end of file diff --git a/DEV2.1/TP11/04_Palette/LectureFichier.java b/DEV2.1/TP11/04_Palette/LectureFichier.java new file mode 100644 index 0000000..520ab8d --- /dev/null +++ b/DEV2.1/TP11/04_Palette/LectureFichier.java @@ -0,0 +1,52 @@ +import java.awt.*; +import java.io.*; +import java.awt.image.BufferedImage; + +public class LectureFichier { + + private BufferedImage image; + + public LectureFichier() { + this.image = new BufferedImage(768, 1024, BufferedImage.TYPE_3BYTE_BGR); + int r; + int g; + int b; + int i = 0; + int j = 0; + Color couleur; + + try { + FileInputStream fichier = new FileInputStream("couleur.bin"); + + while(fichier.available() >= 3) { + try { + r = fichier.read(); + g = fichier.read(); + b = fichier.read(); + couleur = new Color(r, g, b); + this.image.setRGB(i, j, couleur.getRGB()); + i++; + if (i >= 768) { + j++; + i = 0; + } + } catch (IOException e2) { + System.out.println("Erreur d'accès"); + } + } + + try { + fichier.close(); + } catch (IOException e3) { + System.out.println("Erreur de fermeture"); + } + } catch (IOException e1) { + System.out.println("Erreur d'ouverture"); + } + } + + public BufferedImage getImage() { + return this.image; + } + +} \ No newline at end of file diff --git a/DEV2.1/TP11/04_Palette/Main.java b/DEV2.1/TP11/04_Palette/Main.java new file mode 100644 index 0000000..2768c3d --- /dev/null +++ b/DEV2.1/TP11/04_Palette/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + Fenetre fenetre = new Fenetre(); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP11/04_Palette/couleur.bin b/DEV2.1/TP11/04_Palette/couleur.bin new file mode 100644 index 0000000..2d10628 Binary files /dev/null and b/DEV2.1/TP11/04_Palette/couleur.bin differ diff --git a/DEV2.1/TP11/04_Palette/image.bin b/DEV2.1/TP11/04_Palette/image.bin new file mode 100644 index 0000000..1bf996b Binary files /dev/null and b/DEV2.1/TP11/04_Palette/image.bin differ diff --git a/DEV2.1/TP12/01_Memoire/FermetureFenetre.class b/DEV2.1/TP12/01_Memoire/FermetureFenetre.class new file mode 100644 index 0000000..78637b2 Binary files /dev/null and b/DEV2.1/TP12/01_Memoire/FermetureFenetre.class differ diff --git a/DEV2.1/TP12/01_Memoire/FermetureFenetre.java b/DEV2.1/TP12/01_Memoire/FermetureFenetre.java new file mode 100644 index 0000000..d8ca91b --- /dev/null +++ b/DEV2.1/TP12/01_Memoire/FermetureFenetre.java @@ -0,0 +1,97 @@ +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.awt.event.WindowListener; +import java.awt.event.WindowEvent; +import javax.swing.*; + +public class FermetureFenetre implements WindowListener { + + private JPanel panneau; + private JFrame fenetre; + + public FermetureFenetre(JFrame fenetre, JPanel panneau) { + super(); + this.fenetre = fenetre; + this.panneau = panneau; + } + + public void windowActivated(WindowEvent evenement) { + + } // premier plan + + public void windowClosed(WindowEvent evenement) { + + } + public void windowClosing(WindowEvent evenement) { + try { + Dimension dims = this.fenetre.getSize(); + Point loc = this.fenetre.getLocation(); + Color color = this.panneau.getBackground(); + FileOutputStream fichier = new FileOutputStream("windowlocation.bin"); + DataOutputStream flux = new DataOutputStream(fichier); + + try { + flux.writeInt((int) loc.getX()); + flux.writeInt((int) loc.getY()); + flux.writeInt((int) dims.getWidth()); + flux.writeInt((int) dims.getHeight()); + flux.writeInt(color.getRed()); + flux.writeInt(color.getGreen()); + flux.writeInt(color.getBlue()); + } catch (IOException e2){ + System.out.println("Erreur d'écriture"); + } + + try { + flux.close(); + } catch (IOException e3) { + System.out.println("Erreur de fermeture"); + } + } catch (IOException e) { + System.out.println("Erreur d'ouverture"); + } + } // avant fermeture + + public void windowDeactivated(WindowEvent evenement) { + + } // arrière-plan + + public void windowDeiconified(WindowEvent evenement) { + + } // restauration + + public void windowIconified(WindowEvent evenement){ + + } // minimisation + + public void windowOpened(WindowEvent evenement) { + try { + FileInputStream fichier = new FileInputStream("windowlocation.bin"); + DataInputStream flux = new DataInputStream(fichier); + + try { + + if (flux.available() >= 28) { + this.fenetre.setLocation(flux.readInt(), flux.readInt()); + this.fenetre.setSize(flux.readInt(), flux.readInt()); + this.panneau.setBackground(new Color(flux.readInt(), flux.readInt(), flux.readInt())); + System.out.println(this.panneau.getBackground() + ""); + } + + + } catch (IOException e5) { + System.out.println("Erreur de lecture"); + } + + try { + flux.close(); + } catch (IOException e6) { + System.out.println("Erreur de fermeture"); + } + + } catch (IOException e4) { + System.out.println("Erreur d'ouverture"); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/01_Memoire/Fond$1.class b/DEV2.1/TP12/01_Memoire/Fond$1.class new file mode 100644 index 0000000..2cc3264 Binary files /dev/null and b/DEV2.1/TP12/01_Memoire/Fond$1.class differ diff --git a/DEV2.1/TP12/01_Memoire/Fond$2.class b/DEV2.1/TP12/01_Memoire/Fond$2.class new file mode 100644 index 0000000..a4394aa Binary files /dev/null and b/DEV2.1/TP12/01_Memoire/Fond$2.class differ diff --git a/DEV2.1/TP12/01_Memoire/Fond$3.class b/DEV2.1/TP12/01_Memoire/Fond$3.class new file mode 100644 index 0000000..5c95220 Binary files /dev/null and b/DEV2.1/TP12/01_Memoire/Fond$3.class differ diff --git a/DEV2.1/TP12/01_Memoire/Fond.class b/DEV2.1/TP12/01_Memoire/Fond.class new file mode 100644 index 0000000..9be2656 Binary files /dev/null and b/DEV2.1/TP12/01_Memoire/Fond.class differ diff --git a/DEV2.1/TP12/01_Memoire/Fond.java b/DEV2.1/TP12/01_Memoire/Fond.java new file mode 100644 index 0000000..ae69340 --- /dev/null +++ b/DEV2.1/TP12/01_Memoire/Fond.java @@ -0,0 +1,46 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +public class Fond { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + JPanel panneau = new JPanel(); + FermetureFenetre evenementFenetre = new FermetureFenetre(fenetre, panneau); + fenetre.addWindowListener(evenementFenetre); + fenetre.setLocation(100,100); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setLayout(new GridLayout(1, 1)); + + + JButton bouton1 = new JButton("Cyan"); + JButton bouton2 = new JButton("Magenta"); + JButton bouton3 = new JButton("Jaune"); + + bouton1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evenement) { + panneau.setBackground(Color.CYAN); + } + }); + + bouton2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evenement) { + panneau.setBackground(Color.MAGENTA); + } + }); + + bouton3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evenement) { + panneau.setBackground(Color.YELLOW); + } + }); + + panneau.add(bouton1); + panneau.add(bouton2); + panneau.add(bouton3); + + fenetre.add(panneau); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/01_Memoire/windowlocation.bin b/DEV2.1/TP12/01_Memoire/windowlocation.bin new file mode 100644 index 0000000..6d19765 Binary files /dev/null and b/DEV2.1/TP12/01_Memoire/windowlocation.bin differ diff --git a/DEV2.1/TP12/02_Polygone/Fenetre.java b/DEV2.1/TP12/02_Polygone/Fenetre.java new file mode 100644 index 0000000..5018045 --- /dev/null +++ b/DEV2.1/TP12/02_Polygone/Fenetre.java @@ -0,0 +1,16 @@ +import java.awt.*; +import javax.swing.*; + +public class Fenetre extends JFrame { + + public Fenetre() { + this.setSize(500, 600); + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLayout(new GridLayout(1, 1)); + LectureFichier lecture = new LectureFichier(); + EcritureFichier ecriture = new EcritureFichier("test", lecture.getCoordY(), lecture.getNbPoints()); + this.add(new Polygone(lecture.getCoordX(), lecture.getCoordY(), lecture.getNbPoints())); + EcritureFichier ecriture = new EcritureFichier(lecture.getCoordX(), lecture.getCoordY(), lecture.getNbPoints()); + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/02_Polygone/LectureFichier.java b/DEV2.1/TP12/02_Polygone/LectureFichier.java new file mode 100644 index 0000000..157b990 --- /dev/null +++ b/DEV2.1/TP12/02_Polygone/LectureFichier.java @@ -0,0 +1,54 @@ +import java.awt.*; +import java.io.*; + +public class LectureFichier { + + private int[] coordX; + private int[] coordY; + private int nbPoints; + + public LectureFichier() { + + try { + FileInputStream fichier = new FileInputStream("polygone.bin"); + DataInputStream flux = new DataInputStream(fichier); + + this.coordX = new int[flux.available()/8]; + this.coordY = new int[flux.available()/8]; + this.nbPoints = flux.available()/8; + + int compteur = 0; + + try { + while (flux.available() > 0) { + this.coordX[compteur] = flux.readInt(); + this.coordY[compteur] = flux.readInt(); + compteur++; + } + } catch (IOException e2) { + System.out.println("Erreur de lecture"); + } + + try { + flux.close(); + } catch (IOException e3) { + System.out.println("Erreur de fermeture"); + } + + } catch (IOException e) { + System.out.println("Erreur d'ouverture"); + } + } + + public int[] getCoordX() { + return this.coordX; + } + + public int[] getCoordY() { + return this.coordY; + } + + public int getNbPoints() { + return this.nbPoints; + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/02_Polygone/Main.java b/DEV2.1/TP12/02_Polygone/Main.java new file mode 100644 index 0000000..2768c3d --- /dev/null +++ b/DEV2.1/TP12/02_Polygone/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + Fenetre fenetre = new Fenetre(); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/02_Polygone/Polygone.java b/DEV2.1/TP12/02_Polygone/Polygone.java new file mode 100644 index 0000000..a2c203b --- /dev/null +++ b/DEV2.1/TP12/02_Polygone/Polygone.java @@ -0,0 +1,28 @@ +import java.awt.*; +import javax.swing.*; + +public class Polygone extends JComponent { + + private int[] coordX; + private int[] coordY; + private int nbPoints; + + public Polygone(int[] coordX, int[] coordY, int nbPoints) { + this.coordX = coordX; + this.coordY = coordY; + this.nbPoints = nbPoints; + } + + @Override + public void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + + if (this.isOpaque()) { + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + secondPinceau.setColor(Color.BLUE); + secondPinceau.fillPolygon(this.coordX, this.coordY, this.nbPoints); + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/02_Polygone/polygone.bin b/DEV2.1/TP12/02_Polygone/polygone.bin new file mode 100644 index 0000000..329c5a5 Binary files /dev/null and b/DEV2.1/TP12/02_Polygone/polygone.bin differ diff --git a/DEV2.1/TP12/03_Homothetie/EcritureFichier.class b/DEV2.1/TP12/03_Homothetie/EcritureFichier.class new file mode 100644 index 0000000..6b4d03a Binary files /dev/null and b/DEV2.1/TP12/03_Homothetie/EcritureFichier.class differ diff --git a/DEV2.1/TP12/03_Homothetie/EcritureFichier.java b/DEV2.1/TP12/03_Homothetie/EcritureFichier.java new file mode 100644 index 0000000..98baad6 --- /dev/null +++ b/DEV2.1/TP12/03_Homothetie/EcritureFichier.java @@ -0,0 +1,47 @@ +import java.awt.*; +import java.io.*; + +public class EcritureFichier { + + private int[] coordX; + private int[] coordY; + private int nbPoints; + private boolean aMultiplier; + + public EcritureFichier(int[] coordX, int[] coordY, int nbPoints, boolean aMultiplier) { + this.coordX = coordX; + this.coordY = coordY; + this.nbPoints = nbPoints; + this.aMultiplier = aMultiplier; + + try { + FileOutputStream fichier = new FileOutputStream("polygone.bin"); + DataOutputStream flux = new DataOutputStream(fichier); + + try{ + for (int i = 0; i != nbPoints; i++) { + if (this.aMultiplier) { + flux.writeInt(this.coordX[i]*2); + flux.writeInt(this.coordY[i]*2); + } + else { + flux.writeInt(this.coordX[i]/2); + flux.writeInt(this.coordY[i]/2); + } + } + } catch (IOException e2) { + System.out.println("Erreur d'écriture"); + } + + try { + flux.close(); + System.out.println("Fin de l'écriture"); + } catch (IOException e3) { + System.out.println("Erreur de fermeture"); + } + + } catch (IOException e) { + System.out.println("Erreur d'ouverture"); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/03_Homothetie/Fenetre.class b/DEV2.1/TP12/03_Homothetie/Fenetre.class new file mode 100644 index 0000000..a72d747 Binary files /dev/null and b/DEV2.1/TP12/03_Homothetie/Fenetre.class differ diff --git a/DEV2.1/TP12/03_Homothetie/Fenetre.java b/DEV2.1/TP12/03_Homothetie/Fenetre.java new file mode 100644 index 0000000..1bee685 --- /dev/null +++ b/DEV2.1/TP12/03_Homothetie/Fenetre.java @@ -0,0 +1,15 @@ +import java.awt.*; +import javax.swing.*; + +public class Fenetre extends JFrame { + + public Fenetre(boolean aMultiplier) { + this.setSize(500, 600); + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLayout(new GridLayout(1, 1)); + LectureFichier lecture = new LectureFichier(); + this.add(new Polygone(lecture.getCoordX(), lecture.getCoordY(), lecture.getNbPoints())); + EcritureFichier ecriture = new EcritureFichier(lecture.getCoordX(), lecture.getCoordY(), lecture.getNbPoints(), aMultiplier); + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/03_Homothetie/LectureFichier.class b/DEV2.1/TP12/03_Homothetie/LectureFichier.class new file mode 100644 index 0000000..c3179c7 Binary files /dev/null and b/DEV2.1/TP12/03_Homothetie/LectureFichier.class differ diff --git a/DEV2.1/TP12/03_Homothetie/LectureFichier.java b/DEV2.1/TP12/03_Homothetie/LectureFichier.java new file mode 100644 index 0000000..157b990 --- /dev/null +++ b/DEV2.1/TP12/03_Homothetie/LectureFichier.java @@ -0,0 +1,54 @@ +import java.awt.*; +import java.io.*; + +public class LectureFichier { + + private int[] coordX; + private int[] coordY; + private int nbPoints; + + public LectureFichier() { + + try { + FileInputStream fichier = new FileInputStream("polygone.bin"); + DataInputStream flux = new DataInputStream(fichier); + + this.coordX = new int[flux.available()/8]; + this.coordY = new int[flux.available()/8]; + this.nbPoints = flux.available()/8; + + int compteur = 0; + + try { + while (flux.available() > 0) { + this.coordX[compteur] = flux.readInt(); + this.coordY[compteur] = flux.readInt(); + compteur++; + } + } catch (IOException e2) { + System.out.println("Erreur de lecture"); + } + + try { + flux.close(); + } catch (IOException e3) { + System.out.println("Erreur de fermeture"); + } + + } catch (IOException e) { + System.out.println("Erreur d'ouverture"); + } + } + + public int[] getCoordX() { + return this.coordX; + } + + public int[] getCoordY() { + return this.coordY; + } + + public int getNbPoints() { + return this.nbPoints; + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/03_Homothetie/Main.class b/DEV2.1/TP12/03_Homothetie/Main.class new file mode 100644 index 0000000..345f16a Binary files /dev/null and b/DEV2.1/TP12/03_Homothetie/Main.class differ diff --git a/DEV2.1/TP12/03_Homothetie/Main.java b/DEV2.1/TP12/03_Homothetie/Main.java new file mode 100644 index 0000000..9b21a3d --- /dev/null +++ b/DEV2.1/TP12/03_Homothetie/Main.java @@ -0,0 +1,14 @@ +public class Main { + public static void main(String[] args) { + Fenetre fenetre; + try { + if (args[0].equals("diviser")) { + fenetre = new Fenetre(false); + } + else { + fenetre = new Fenetre(true); + } + } catch (ArrayIndexOutOfBoundsException e) { + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/03_Homothetie/Polygone.class b/DEV2.1/TP12/03_Homothetie/Polygone.class new file mode 100644 index 0000000..f8b114d Binary files /dev/null and b/DEV2.1/TP12/03_Homothetie/Polygone.class differ diff --git a/DEV2.1/TP12/03_Homothetie/Polygone.java b/DEV2.1/TP12/03_Homothetie/Polygone.java new file mode 100644 index 0000000..a2c203b --- /dev/null +++ b/DEV2.1/TP12/03_Homothetie/Polygone.java @@ -0,0 +1,28 @@ +import java.awt.*; +import javax.swing.*; + +public class Polygone extends JComponent { + + private int[] coordX; + private int[] coordY; + private int nbPoints; + + public Polygone(int[] coordX, int[] coordY, int nbPoints) { + this.coordX = coordX; + this.coordY = coordY; + this.nbPoints = nbPoints; + } + + @Override + public void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + + if (this.isOpaque()) { + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + secondPinceau.setColor(Color.BLUE); + secondPinceau.fillPolygon(this.coordX, this.coordY, this.nbPoints); + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/03_Homothetie/polygone.bin b/DEV2.1/TP12/03_Homothetie/polygone.bin new file mode 100644 index 0000000..329c5a5 Binary files /dev/null and b/DEV2.1/TP12/03_Homothetie/polygone.bin differ diff --git a/DEV2.1/TP12/04_Trainee/ClicCase.class b/DEV2.1/TP12/04_Trainee/ClicCase.class new file mode 100644 index 0000000..37c35ee Binary files /dev/null and b/DEV2.1/TP12/04_Trainee/ClicCase.class differ diff --git a/DEV2.1/TP12/04_Trainee/ClicCase.java b/DEV2.1/TP12/04_Trainee/ClicCase.java new file mode 100644 index 0000000..97ecebb --- /dev/null +++ b/DEV2.1/TP12/04_Trainee/ClicCase.java @@ -0,0 +1,40 @@ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class ClicCase implements MouseListener { + + private JPanel[][] cases; + private int[][] grille; + private int caseX; + private int caseY; + + public ClicCase(JPanel[][] cases, int[][] grille, int caseX, int caseY) { + this.cases = cases; + this.grille = grille; + this.caseX = caseX; + this.caseY = caseY; + } + + public void mouseClicked(MouseEvent evenement) { + this.cases[this.caseX][this.caseY].setLayout(new GridLayout()); + this.cases[this.caseX][this.caseY].add(new Image()); + } // 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é + +} \ No newline at end of file diff --git a/DEV2.1/TP12/04_Trainee/Fenetre.class b/DEV2.1/TP12/04_Trainee/Fenetre.class new file mode 100644 index 0000000..02b03dc Binary files /dev/null and b/DEV2.1/TP12/04_Trainee/Fenetre.class differ diff --git a/DEV2.1/TP12/04_Trainee/Fenetre.java b/DEV2.1/TP12/04_Trainee/Fenetre.java new file mode 100644 index 0000000..92bc376 --- /dev/null +++ b/DEV2.1/TP12/04_Trainee/Fenetre.java @@ -0,0 +1,29 @@ +import java.awt.*; +import javax.swing.*; +import java.util.Arrays; + +public class Fenetre extends JFrame { + + public Fenetre() { + this.setSize(500,500); + this.setLocation(100,100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + this.setLayout(new GridLayout(10, 10)); + + JPanel[][] cases = new JPanel[10][10]; + int[][] grille = new int[10][10]; + + for (int i = 0; i != 10; i++) { + for (int j = 0; j != 10; j++) { + cases[i][j] = new JPanel(); + cases[i][j].setBackground(new Color(37, 150, 190)); + cases[i][j].setBorder(BorderFactory.createLineBorder(Color.WHITE)); + cases[i][j].addMouseListener(new ClicCase(cases, grille, i, j)); + this.add(cases[i][j]); + + grille[i][j] = 0; + } + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/04_Trainee/GestionGrille.class b/DEV2.1/TP12/04_Trainee/GestionGrille.class new file mode 100644 index 0000000..ee0effa Binary files /dev/null and b/DEV2.1/TP12/04_Trainee/GestionGrille.class differ diff --git a/DEV2.1/TP12/04_Trainee/GestionGrille.java b/DEV2.1/TP12/04_Trainee/GestionGrille.java new file mode 100644 index 0000000..de3e760 --- /dev/null +++ b/DEV2.1/TP12/04_Trainee/GestionGrille.java @@ -0,0 +1,35 @@ +import java.awt.*; + +public class GestionGrille { + + private int[][] grille; + private Point[] coordsTrainee; + private Point coordJoueur; + + public GestionGrille(Point[] coordsTrainee, Point coordJoueur) { + for (int i = 0; i != 10; i++) { + for (int j = 0; j != 10; j++) { + this.grille[i][j] = 0; + } + } + this.coordsTrainee = coordsTrainee; + this.coordJoueur = coordJoueur; + } + + public boolean deplacementPossible(Point destination) { + if (this.coordJoueur.getX() == destination.getX() + && this.coordJoueur.getY() == destination.getY()-1) { + return true; + } + else if (this.coordJoueur.getX() == destination.getX() + && this.coordJoueur.getY() == destination.getY()+1) { + return true; + } + else if (this.coordJoueur.getX() == destination.getX()+1 + && this.coordJoueur.getY() == destination.getY()) { + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/DEV2.1/TP12/04_Trainee/Image.java b/DEV2.1/TP12/04_Trainee/Image.java new file mode 100644 index 0000000..98e0dae --- /dev/null +++ b/DEV2.1/TP12/04_Trainee/Image.java @@ -0,0 +1,13 @@ +import java.awt.*; +import javax.swing.*; + +public class Image extends JComponent { + + @Override + public void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + + Image img = Toolkit.getDefaultToolkit().getImage("vaisseau.png"); + secondPinceau.drawImage(img, 0, 0, this); + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/05_Degres/Main.class b/DEV2.1/TP12/04_Trainee/Main.class similarity index 100% rename from DEV2.1/TP10/05_Degres/Main.class rename to DEV2.1/TP12/04_Trainee/Main.class diff --git a/DEV2.1/TP12/04_Trainee/Main.java b/DEV2.1/TP12/04_Trainee/Main.java new file mode 100644 index 0000000..2768c3d --- /dev/null +++ b/DEV2.1/TP12/04_Trainee/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + Fenetre fenetre = new Fenetre(); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP12/04_Trainee/vaisseau.png b/DEV2.1/TP12/04_Trainee/vaisseau.png new file mode 100644 index 0000000..c904164 Binary files /dev/null and b/DEV2.1/TP12/04_Trainee/vaisseau.png differ diff --git a/DEV2.1/TP13/01_Devinette/Main.class b/DEV2.1/TP13/01_Devinette/Main.class new file mode 100644 index 0000000..920a9d4 Binary files /dev/null and b/DEV2.1/TP13/01_Devinette/Main.class differ diff --git a/DEV2.1/TP13/01_Devinette/Main.java b/DEV2.1/TP13/01_Devinette/Main.java new file mode 100644 index 0000000..bacc2ef --- /dev/null +++ b/DEV2.1/TP13/01_Devinette/Main.java @@ -0,0 +1,50 @@ +import java.awt.*; +import java.io.*; +import java.util.Random; + +public class Main { + public static void main(String[] args) { + Random aleatoire = new Random(); + int aDeviner = aleatoire.nextInt(100) + 1; + + BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); + String essai = "-1"; + + try { + System.out.println("Essai n°1 : Veuillez entrer un nombre (1 à 100) : "); + essai = console.readLine(); + } catch (IOException e) { + System.err.println("Erreur de console."); + } + try { + for (int i = 2; i != 6; i++) { + if (Integer.parseInt(essai) > aDeviner) { + System.out.println("-"); + } + + else if (Integer.parseInt(essai) == aDeviner) { + break; + } + + else { + System.out.println("+"); + } + System.out.println("Essai n°" + i + " : Veuillez entrer un nombre (1 à 100) : "); + essai = console.readLine(); + } + + if (Integer.parseInt(essai) == aDeviner) { + System.out.println("Nombre trouvé."); + } + else { + System.out.println("Nombre non trouvé après 5 essais."); + } + + + } catch (IOException e) { + System.err.println("Erreur de console."); + } catch (NumberFormatException e2) { + System.err.println("Veuillez n'entrer que des nombres."); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP13/02_Image/Fenetre.class b/DEV2.1/TP13/02_Image/Fenetre.class new file mode 100644 index 0000000..753d72c Binary files /dev/null and b/DEV2.1/TP13/02_Image/Fenetre.class differ diff --git a/DEV2.1/TP13/02_Image/Fenetre.java b/DEV2.1/TP13/02_Image/Fenetre.java new file mode 100644 index 0000000..2cf238c --- /dev/null +++ b/DEV2.1/TP13/02_Image/Fenetre.java @@ -0,0 +1,12 @@ +import java.awt.*; +import javax.swing.*; + +public class Fenetre extends JFrame { + public Fenetre() { + this.setSize(32, 35); + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLayout(new GridLayout(1, 1)); + this.add(new Image()); + } +} \ No newline at end of file diff --git a/DEV2.1/TP13/02_Image/Image.class b/DEV2.1/TP13/02_Image/Image.class new file mode 100644 index 0000000..2672948 Binary files /dev/null and b/DEV2.1/TP13/02_Image/Image.class differ diff --git a/DEV2.1/TP13/02_Image/Image.java b/DEV2.1/TP13/02_Image/Image.java new file mode 100644 index 0000000..f967139 --- /dev/null +++ b/DEV2.1/TP13/02_Image/Image.java @@ -0,0 +1,13 @@ +import java.awt.*; +import javax.swing.*; + +public class Image extends JComponent { + + @Override + public void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + + LectureFichier fichier = new LectureFichier(); + secondPinceau.drawImage(fichier.getImage(), 0, 0, this); + } +} \ No newline at end of file diff --git a/DEV2.1/TP13/02_Image/LectureFichier.class b/DEV2.1/TP13/02_Image/LectureFichier.class new file mode 100644 index 0000000..f3fd318 Binary files /dev/null and b/DEV2.1/TP13/02_Image/LectureFichier.class differ diff --git a/DEV2.1/TP13/02_Image/LectureFichier.java b/DEV2.1/TP13/02_Image/LectureFichier.java new file mode 100644 index 0000000..24b8208 --- /dev/null +++ b/DEV2.1/TP13/02_Image/LectureFichier.java @@ -0,0 +1,74 @@ +import java.awt.*; +import java.io.*; +import java.awt.image.BufferedImage; + +public class LectureFichier { + + private BufferedImage image; + + public LectureFichier() { + try { + BufferedReader lecture = new BufferedReader(new FileReader("image.xpm")); + + try { + for (int i = 0; i != 3; i++) { + lecture.readLine(); + } + + String infos = lecture.readLine(); + infos = infos.replaceAll("\"", ""); + String[] infosTab = infos.split(" "); + for (String info : infosTab) { + System.out.println(info); + } + this.image = new BufferedImage(Integer.parseInt(infosTab[0]), Integer.parseInt(infosTab[1]), BufferedImage.TYPE_3BYTE_BGR); + + char[] caracteres = new char[15]; + Color[] couleurs = new Color[15]; + + for (int i = 0; i != Integer.parseInt(infosTab[2]); i++) { + String ligne = lecture.readLine(); + caracteres[i] = ligne.charAt(1); + + int[] rgb = { + Integer.parseInt(ligne.substring(6,8), 16), + Integer.parseInt(ligne.substring(8,10), 16), + Integer.parseInt(ligne.substring(10,12), 16) + }; + + couleurs[i] = new Color(rgb[0], rgb[1], rgb[2]); + + } + + lecture.readLine(); + + for (int i = 0; i != Integer.parseInt(infosTab[1]); i++) { + String ligne = lecture.readLine().replaceAll("\"", ""); + ligne = ligne.substring(0, ligne.length()-1); + + for (int j = 0; j != ligne.length(); j++) { + for (int k = 0; k != caracteres.length; k++) { + if (caracteres[k] == ligne.charAt(j)) { + this.image.setRGB(i, j, couleurs[k].getRGB()); + } + } + } + } + } catch (IOException e2) { + System.err.println("Erreur d'écriture"); + } + + try { + lecture.close(); + } catch (IOException e3) { + System.err.println("Erreur de fermeture"); + } + } catch (IOException e1) { + System.err.println("Erreur d'ouverture"); + } + } + + public BufferedImage getImage() { + return this.image; + } +} \ No newline at end of file diff --git a/DEV2.1/TP13/02_Image/Main.class b/DEV2.1/TP13/02_Image/Main.class new file mode 100644 index 0000000..4bfefb8 Binary files /dev/null and b/DEV2.1/TP13/02_Image/Main.class differ diff --git a/DEV2.1/TP13/02_Image/Main.java b/DEV2.1/TP13/02_Image/Main.java new file mode 100644 index 0000000..2768c3d --- /dev/null +++ b/DEV2.1/TP13/02_Image/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + Fenetre fenetre = new Fenetre(); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP13/02_Image/image.xpm b/DEV2.1/TP13/02_Image/image.xpm new file mode 100644 index 0000000..1b6e40c --- /dev/null +++ b/DEV2.1/TP13/02_Image/image.xpm @@ -0,0 +1,56 @@ +/* XPM */ +static char *test[] = { +/* columns rows colors chars-per-pixel */ +"32 35 15 1", +" c #000000", +". c #731810", +"X c #A52918", +"o c #FF5210", +"O c #D64221", +"+ c #FF8C10", +"@ c #FFBD29", +"# c #FFE739", +"$ c #FFBD4A", +"% c #FFFF63", +"& c #9C8C8C", +"* c #C6B5B5", +"= c #B0D8D0", +"- c #EFDEDE", +"; c #FFFFFF", +/* pixels */ +"================================", +"================================", +"=============O====o=============", +"==============O==o#o============", +"==============oO=o@o============", +"==============ooOo+o============", +"==========o===o+o=o=============", +"=========o@o=Oo++o==============", +"=========ooo=o+@+o==============", +"==========o=O++@+oO=============", +"============o+@#@o+O============", +"===========O+@#;#+@+o===========", +"===========O+#;;;+#@o===========", +"===========o@;;;;@#o============", +"=== =======..........======= ===", +"== = = ==..XXOOooOOXX..== = = ==", +"= = =.XXoOO OOoXX.= = =", +"== XXXX % % XXXX ==", +"=== oX XXX XXX Xo ===", +"=====X o$X -& &- X$o X=====", +"=====X o$$o ;;;;;; o$$o X=====", +"===== Xoo$$$ -;oo;- $$$ooX =====", +"===== OoX$Xoo ;;;; ooX$XoO =====", +"===== Xo o O -;;- O o oX =====", +"====== O O = -- = O O ======", +"======= = *= o o =* = =======", +"=========== * oooo * ===========", +"=========== oooooo ===========", +"========== XooooooX ==========", +"========= X XooooooX X =========", +"========= OooOOOOOOooO =========", +"========== oooooooo ==========", +"============ ============", +"================================", +"================================" +}; diff --git a/DEV2.1/test.class b/DEV2.1/test.class new file mode 100644 index 0000000..9ca75f1 Binary files /dev/null and b/DEV2.1/test.class differ diff --git a/DEV2.1/test.java b/DEV2.1/test.java new file mode 100644 index 0000000..3b49a4f --- /dev/null +++ b/DEV2.1/test.java @@ -0,0 +1,7 @@ +import java.awt.*; + +public class test { + public static void main(String[] args) { + System.out.println("" + Math.pow(2, 5)); + } +} \ No newline at end of file