diff --git a/DEV3.2/TP3/Luminance/Luminance.class b/DEV3.2/TP3/Luminance/Luminance.class new file mode 100644 index 0000000..55b2d8c Binary files /dev/null and b/DEV3.2/TP3/Luminance/Luminance.class differ diff --git a/DEV3.2/TP3/Luminance/Luminance.java b/DEV3.2/TP3/Luminance/Luminance.java new file mode 100644 index 0000000..53a580f --- /dev/null +++ b/DEV3.2/TP3/Luminance/Luminance.java @@ -0,0 +1,52 @@ +import java.awt.Graphics; +import java.awt.Color; +import javax.swing.*; +import java.awt.event.*; +import java.util.*; + +public class Luminance extends JPanel implements MouseListener{ + + public Luminance(){ + super(); + } + + boolean listenoncréer = true; + + protected void paintComponent(Graphics pinceau) { + // obligatoire : on cree un nouveau pinceau pour pouvoir le modifier plus tard + Graphics pinceau2 = pinceau.create(); + List paralleloliste = new ArrayList<>(); + int color; + if (this.isOpaque()) { + // obligatoire : on repeint toute la surface avec la couleur de fond + pinceau2.setColor(Color.DARK_GRAY); + pinceau2.fillRect(0, 0, this.getWidth(), this.getHeight()); + } if(listenoncréer){ + for (int i=0; i<30; i++){ + Random rand = new Random(); + color = rand.nextInt(256); + paralleloliste.add(i,color); + } listenoncréer = false; + } for (int i=0; i<10; i++){ + int x[] = {0+(this.getWidth()/11)*i,80+(this.getWidth()/11)*i,180+(this.getWidth()/11)*i,100+(this.getWidth()/11)*i}; + int y[] = {this.getHeight()-10,10,10,this.getHeight()-10}; + pinceau2.setColor(new Color(paralleloliste.get(0+3*i),paralleloliste.get(1+3*i),paralleloliste.get(2+3*i))); + pinceau2.fillPolygon(x,y,4); + } + } + + public void mouseClicked(MouseEvent e){ + } + + public void mouseEntered(MouseEvent e){ + } + + public void mouseExited(MouseEvent e){ + } + + public void mousePressed(MouseEvent e){ + } + + public void mouseReleased(MouseEvent e){ + } +} \ No newline at end of file diff --git a/DEV3.2/TP3/Luminance/MainLuminance.class b/DEV3.2/TP3/Luminance/MainLuminance.class new file mode 100644 index 0000000..f37adfb Binary files /dev/null and b/DEV3.2/TP3/Luminance/MainLuminance.class differ diff --git a/DEV3.2/TP3/Luminance/MainLuminance.java b/DEV3.2/TP3/Luminance/MainLuminance.java new file mode 100644 index 0000000..1d910ed --- /dev/null +++ b/DEV3.2/TP3/Luminance/MainLuminance.java @@ -0,0 +1,18 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; +import java.util.*; + +public class MainLuminance{ + public static void main(String[] args) { + + JFrame fenetre = new JFrame(); + Luminance pan = new Luminance(); + fenetre.setSize(1200, 250); + fenetre.setLocation(0, 0); + fenetre.addMouseListener(pan); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setContentPane(pan); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV3.2/TP4/Arithmetique/MainArithmetique.class b/DEV3.2/TP4/Arithmetique/MainArithmetique.class new file mode 100644 index 0000000..037cc3e Binary files /dev/null and b/DEV3.2/TP4/Arithmetique/MainArithmetique.class differ diff --git a/DEV3.2/TP4/Arithmetique/MainArithmetique.java b/DEV3.2/TP4/Arithmetique/MainArithmetique.java new file mode 100644 index 0000000..f72580f --- /dev/null +++ b/DEV3.2/TP4/Arithmetique/MainArithmetique.java @@ -0,0 +1,31 @@ +import java.util.*; + +public class MainArithmetique { + + public static String calculateur(String val, ArrayDeque pile){ + switch(val){ + case "+": + return String.valueOf(Integer.parseInt(calculateur(pile.pop(), pile))+Integer.parseInt(calculateur(pile.pop(), pile))); + case "-": + return String.valueOf(-(Integer.parseInt(calculateur(pile.pop(), pile)))+Integer.parseInt(calculateur(pile.pop(), pile))); + case "x": + return String.valueOf(Integer.parseInt(calculateur(pile.pop(), pile))*Integer.parseInt(calculateur(pile.pop(), pile))); + case "/": + return String.valueOf(Integer.parseInt(calculateur(pile.pop(), pile))/Integer.parseInt(calculateur(pile.pop(), pile))); + default: + return val; + } + } + + public static void main(String[] args) { + ArrayDeque pile = new ArrayDeque(args.length); + String result; + + for (int i=0; i