Controle machine
This commit is contained in:
13
DEV2.1/controle_machine_1/CM1/01_Filtre/Filtre.java
Normal file
13
DEV2.1/controle_machine_1/CM1/01_Filtre/Filtre.java
Normal file
@@ -0,0 +1,13 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class Filtre {
|
||||
public static String minusculesDansChaine(String chaine) {
|
||||
String chaineFinale = "";
|
||||
for (int i = 0; i != chaine.length(); i++) {
|
||||
if(Character.isLowerCase(chaine.charAt(i))) {
|
||||
chaineFinale += chaine.charAt(i);
|
||||
}
|
||||
}
|
||||
return chaineFinale;
|
||||
}
|
||||
}
|
14
DEV2.1/controle_machine_1/CM1/01_Filtre/Main.java
Normal file
14
DEV2.1/controle_machine_1/CM1/01_Filtre/Main.java
Normal file
@@ -0,0 +1,14 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Tests de la méthode
|
||||
/* String texte = "CeCi eSt uN TesT";
|
||||
String texte2 = "mMiAnJuUsScCuUlLeEsS ";
|
||||
System.out.println(Filtre.minusculesDansChaine(texte));
|
||||
System.out.println(Filtre.minusculesDansChaine(texte2)); */
|
||||
|
||||
for (String chaine : args) {
|
||||
System.out.println(Filtre.minusculesDansChaine(chaine));
|
||||
}
|
||||
}
|
||||
}
|
16
DEV2.1/controle_machine_1/CM1/02_Exquis/Exquis.java
Normal file
16
DEV2.1/controle_machine_1/CM1/02_Exquis/Exquis.java
Normal file
@@ -0,0 +1,16 @@
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class Exquis {
|
||||
|
||||
private String[] chaines;
|
||||
|
||||
public Exquis(String[] chaines) {
|
||||
this.chaines = chaines;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Random aleatoire = new Random();
|
||||
return this.chaines[Math.abs(aleatoire.nextInt()) % this.chaines.length];
|
||||
}
|
||||
}
|
35
DEV2.1/controle_machine_1/CM1/02_Exquis/Main.java
Normal file
35
DEV2.1/controle_machine_1/CM1/02_Exquis/Main.java
Normal file
@@ -0,0 +1,35 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
String[] sujets = {
|
||||
"Luc",
|
||||
"Denis",
|
||||
"Régine",
|
||||
"Selma",
|
||||
"Frédéric"
|
||||
};
|
||||
|
||||
String[] verbes = {
|
||||
"aime",
|
||||
"déteste",
|
||||
"tue",
|
||||
"mange",
|
||||
"épouse"
|
||||
};
|
||||
|
||||
String[] complements = {
|
||||
"Windows",
|
||||
"les pommes",
|
||||
"Elizabeth II",
|
||||
"les batyscaphes" // Je sais même pas si c'est un nom commun en vrai
|
||||
};
|
||||
|
||||
Exquis sujet = new Exquis(sujets);
|
||||
Exquis verbe = new Exquis(verbes);
|
||||
Exquis complement = new Exquis(complements);
|
||||
|
||||
for (int i = 0; i != 5; i++) {
|
||||
System.out.println(sujet + " " + verbe + " " + complement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
BIN
DEV2.1/controle_machine_1/CM1/03_Compteur/6.png
Normal file
BIN
DEV2.1/controle_machine_1/CM1/03_Compteur/6.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
31
DEV2.1/controle_machine_1/CM1/03_Compteur/Fenetre.java
Normal file
31
DEV2.1/controle_machine_1/CM1/03_Compteur/Fenetre.java
Normal file
@@ -0,0 +1,31 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
public Fenetre() {
|
||||
this.setSize(250, 300);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
JPanel panneauHaut = new JPanel();
|
||||
JPanel panneauBas = new JPanel();
|
||||
JPanel panneauMilieu = new JPanel();
|
||||
|
||||
JButton boutonHaut = new JButton("\u25B2");
|
||||
JButton boutonBas = new JButton("\u25BC");
|
||||
Six imageSix = new Six();
|
||||
|
||||
boutonHaut.setHorizontalAlignment(JButton.CENTER);
|
||||
boutonBas.setHorizontalAlignment(JButton.CENTER);
|
||||
|
||||
panneauHaut.add(boutonHaut);
|
||||
panneauBas.add(boutonBas);
|
||||
panneauMilieu.add(imageSix);
|
||||
|
||||
this.add(panneauHaut, BorderLayout.NORTH);
|
||||
this.add(panneauBas, BorderLayout.SOUTH);
|
||||
this.add(imageSix, BorderLayout.CENTER);
|
||||
}
|
||||
}
|
6
DEV2.1/controle_machine_1/CM1/03_Compteur/Main.java
Normal file
6
DEV2.1/controle_machine_1/CM1/03_Compteur/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
19
DEV2.1/controle_machine_1/CM1/03_Compteur/Six.java
Normal file
19
DEV2.1/controle_machine_1/CM1/03_Compteur/Six.java
Normal file
@@ -0,0 +1,19 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Six 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());
|
||||
}
|
||||
|
||||
Image img = Toolkit.getDefaultToolkit().getImage("6.png");
|
||||
// On place l'image au milieu de son composant puis on soustrait par la moitié des dimensions de l'image (55x80)
|
||||
secondPinceau.drawImage(img, this.getWidth()/2 - 27 , this.getHeight()/2 - 40, this);
|
||||
}
|
||||
}
|
19
DEV2.1/controle_machine_1/CM1/04_Illumination/Fenetre.java
Normal file
19
DEV2.1/controle_machine_1/CM1/04_Illumination/Fenetre.java
Normal file
@@ -0,0 +1,19 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
public Fenetre() {
|
||||
this.setSize(300, 400);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new GridLayout(1, 1));
|
||||
|
||||
JPanel fond = new JPanel();
|
||||
fond.setBackground(Color.BLACK);
|
||||
this.add(fond);
|
||||
|
||||
GestionMolette molette = new GestionMolette(fond);
|
||||
this.addMouseWheelListener(molette);
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class GestionMolette implements MouseWheelListener {
|
||||
|
||||
private JPanel fond;
|
||||
|
||||
public GestionMolette(JPanel fond) {
|
||||
this.fond = fond;
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent evenement) {
|
||||
if (evenement.getWheelRotation() < 0) {
|
||||
this.fond.setBackground(Color.WHITE);
|
||||
}
|
||||
else {
|
||||
this.fond.setBackground(Color.BLACK);
|
||||
}
|
||||
}
|
||||
}
|
6
DEV2.1/controle_machine_1/CM1/04_Illumination/Main.java
Normal file
6
DEV2.1/controle_machine_1/CM1/04_Illumination/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user