TP
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
BIN
DEV3.1/TP4:OrganisationCode/GalerieConfirmation/Changement.class
Normal file
@ -9,8 +9,8 @@ public class Changement{
|
|||||||
InputStream file = loader.getResourceAsStream("Main.java");
|
InputStream file = loader.getResourceAsStream("Main.java");
|
||||||
InputStream file2 = loader.getResourceAsStream("Listeimage.java");
|
InputStream file2 = loader.getResourceAsStream("Listeimage.java");
|
||||||
static public void fenetreCliquer(int LR){
|
static public void fenetreCliquer(int LR){
|
||||||
Main.fenetre.remove(Main.pan);
|
Main.fenetre.remove(Main.fenetre.pan);
|
||||||
Main.pan.remove(Listeimage.liste[Listeimage.index]);
|
Main.fenetre.pan.remove(Listeimage.liste[Listeimage.index]);
|
||||||
if (LR==1){
|
if (LR==1){
|
||||||
Listeimage.index=Listeimage.index+1;
|
Listeimage.index=Listeimage.index+1;
|
||||||
if(Listeimage.index>4){
|
if(Listeimage.index>4){
|
||||||
@ -22,8 +22,8 @@ public class Changement{
|
|||||||
Listeimage.index=4;
|
Listeimage.index=4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Main.pan.add(Listeimage.liste[Listeimage.index]);
|
Main.fenetre.pan.add(Listeimage.liste[Listeimage.index]);
|
||||||
Main.fenetre.setContentPane(Main.pan);
|
Main.fenetre.setContentPane(Main.fenetre.pan);
|
||||||
Main.fenetre.repaint();
|
Main.fenetre.revalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
DEV3.1/TP4:OrganisationCode/GalerieConfirmation/Fenetre$1.class
Normal file
BIN
DEV3.1/TP4:OrganisationCode/GalerieConfirmation/Fenetre.class
Normal file
45
DEV3.1/TP4:OrganisationCode/GalerieConfirmation/Fenetre.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class Fenetre extends JFrame{
|
||||||
|
|
||||||
|
static Galerie pan = new Galerie();
|
||||||
|
private ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
|
private InputStream file = loader.getResourceAsStream("Galerie.java");
|
||||||
|
|
||||||
|
public Fenetre(){
|
||||||
|
pan.add(Listeimage.liste[Listeimage.index]);
|
||||||
|
this.setSize(250, 250);
|
||||||
|
this.setLocation(500, 500);
|
||||||
|
this.addMouseListener(pan);
|
||||||
|
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
this.setContentPane(pan);
|
||||||
|
|
||||||
|
addWindowListener(new WindowAdapter()
|
||||||
|
{
|
||||||
|
public void windowClosing(WindowEvent e)
|
||||||
|
{
|
||||||
|
if(fermerFenetre()==true){
|
||||||
|
dispose();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean fermerFenetre() {
|
||||||
|
JOptionPane option = new JOptionPane("Voulez-vous vraiment quitter ce programme ?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
|
||||||
|
JDialog confirmation = option.createDialog(this, "Confirmation de fermeture");
|
||||||
|
|
||||||
|
confirmation.setSize(400, 120);
|
||||||
|
confirmation.setLocation(450, 550);
|
||||||
|
confirmation.setVisible(true);
|
||||||
|
int result = (int) option.getValue();
|
||||||
|
confirmation.dispose();
|
||||||
|
return result == JOptionPane.YES_OPTION;
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV3.1/TP4:OrganisationCode/GalerieConfirmation/Galerie.class
Normal file
@ -9,10 +9,6 @@ public class Galerie extends JPanel implements MouseListener{
|
|||||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
InputStream file = loader.getResourceAsStream("Changement.java");
|
InputStream file = loader.getResourceAsStream("Changement.java");
|
||||||
|
|
||||||
public Galerie(){
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseClicked(MouseEvent e){
|
public void mouseClicked(MouseEvent e){
|
||||||
int x = e.getX();
|
int x = e.getX();
|
||||||
if (x <= this.getWidth()/5){
|
if (x <= this.getWidth()/5){
|
BIN
DEV3.1/TP4:OrganisationCode/GalerieConfirmation/Listeimage.class
Normal file
@ -7,11 +7,6 @@ import java.io.*;
|
|||||||
public class Listeimage{
|
public class Listeimage{
|
||||||
|
|
||||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
InputStream file = loader.getResourceAsStream("img/image1.jpg");
|
|
||||||
InputStream file2 = loader.getResourceAsStream("img/image2.jpg");
|
|
||||||
InputStream file3 = loader.getResourceAsStream("img/image3.jpg");
|
|
||||||
InputStream file4 = loader.getResourceAsStream("img/image4.jpg");
|
|
||||||
InputStream file5 = loader.getResourceAsStream("img/image5.jpg");
|
|
||||||
|
|
||||||
static JLabel image1 = new JLabel(new ImageIcon("./img/image1.jpg"));
|
static JLabel image1 = new JLabel(new ImageIcon("./img/image1.jpg"));
|
||||||
static JLabel image2 = new JLabel(new ImageIcon("./img/image2.jpg"));
|
static JLabel image2 = new JLabel(new ImageIcon("./img/image2.jpg"));
|
BIN
DEV3.1/TP4:OrganisationCode/GalerieConfirmation/Main.class
Normal file
@ -4,22 +4,16 @@ import java.util.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class Main{
|
public class Main{
|
||||||
|
|
||||||
static JFrame fenetre = new JFrame();
|
|
||||||
static Galerie pan = new Galerie();
|
|
||||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
InputStream file = loader.getResourceAsStream("Galerie.java");
|
InputStream file = loader.getResourceAsStream("Galerie.java");
|
||||||
InputStream file2 = loader.getResourceAsStream("Listeimage.java");
|
InputStream file2 = loader.getResourceAsStream("Listeimage.java");
|
||||||
InputStream file3 = loader.getResourceAsStream("Changement.java");
|
InputStream file3 = loader.getResourceAsStream("Changement.java");
|
||||||
|
InputStream file4 = loader.getResourceAsStream("Fenetre.java");
|
||||||
|
static Fenetre fenetre = new Fenetre();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
pan.add(Listeimage.liste[Listeimage.index]);
|
|
||||||
fenetre.setSize(250, 250);
|
|
||||||
fenetre.setLocation(250, 250);
|
|
||||||
fenetre.addMouseListener(pan);
|
|
||||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
fenetre.setContentPane(pan);
|
|
||||||
fenetre.setVisible(true);
|
fenetre.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
BIN
DEV3.1/TP4:OrganisationCode/galerie.jar
Normal file
BIN
DEV3.2/TP2/FibonacciLent.class
Normal file
19
DEV3.2/TP2/FibonacciLent.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
public class FibonacciLent{
|
||||||
|
|
||||||
|
public static long fibo(long indice){
|
||||||
|
if(indice==0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(indice==1){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return fibo(indice-1)+fibo(indice-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String args[]){
|
||||||
|
long indicemax=Long.parseUnsignedLong(args[0]);
|
||||||
|
System.out.println("Le terme n°"+indicemax+" de la suite de Fibonacci est égal à "+fibo(indicemax));
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV3.2/TP2/FibonacciRapide.class
Normal file
39
DEV3.2/TP2/FibonacciRapide.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class FibonacciRapide {
|
||||||
|
|
||||||
|
private static int indentation;
|
||||||
|
private static HashMap<Long, Long> buffer = new HashMap<>();
|
||||||
|
|
||||||
|
public static long fibo(long indice) {
|
||||||
|
if (indice == 0) {
|
||||||
|
return 0;
|
||||||
|
} else if (indice == 1) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
if (buffer.containsKey(indice)) {
|
||||||
|
return buffer.get(indice);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < indentation; i++) {
|
||||||
|
System.out.print(" ");
|
||||||
|
}
|
||||||
|
System.out.println("Terme n°"+indice);
|
||||||
|
indentation++;
|
||||||
|
long result = fibo(indice - 1) + fibo(indice - 2);
|
||||||
|
buffer.put(indice, result);
|
||||||
|
for (int i = 0; i < indentation-1; i++) {
|
||||||
|
System.out.print(" ");
|
||||||
|
}
|
||||||
|
indentation--;
|
||||||
|
System.out.println("Résultat du calcul: "+result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
long indicemax = Long.parseUnsignedLong(args[0]);
|
||||||
|
indentation=0;
|
||||||
|
System.out.println("Le terme n°" + indicemax + " de la suite de Fibonacci est égal à " + fibo(indicemax));
|
||||||
|
}
|
||||||
|
}
|