Ajout
This commit is contained in:
parent
a75ff44f14
commit
edc92ac142
Binary file not shown.
Binary file not shown.
@ -1,16 +1,22 @@
|
||||
import java.lang.Object;
|
||||
import java.util.Currency;
|
||||
|
||||
public class Monnaie{
|
||||
public static void main(String args[]){
|
||||
if(args.length > 0){
|
||||
public class Monnaie {
|
||||
public static void main(String args[]) {
|
||||
DeviseInfoPrinter deviseInfoPrinter = new DeviseInfoPrinter();
|
||||
|
||||
if (args.length > 0) {
|
||||
String nom_monnaie = args[0];
|
||||
Currency monnaie = Currency.getInstance(nom_monnaie);
|
||||
System.out.println("Code numerique : "+monnaie.getNumericCode());
|
||||
System.out.println("Symbole : "+ monnaie.getSymbol());
|
||||
}else{
|
||||
deviseInfoPrinter.printDeviseInfo(nom_monnaie);
|
||||
} else {
|
||||
System.out.println("Merci d'indiquer une valeur EX : \"EUR\"");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class DeviseInfoPrinter {
|
||||
public void printDeviseInfo(String nom_monnaie) {
|
||||
Currency monnaie = Currency.getInstance(nom_monnaie);
|
||||
System.out.println("Code numerique : " + monnaie.getNumericCode());
|
||||
System.out.println("Symbole : " + monnaie.getSymbol());
|
||||
}
|
||||
}
|
BIN
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO4/Ciel.class
Normal file
BIN
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO4/Ciel.class
Normal file
Binary file not shown.
40
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO4/Ciel.java
Normal file
40
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO4/Ciel.java
Normal file
@ -0,0 +1,40 @@
|
||||
import javax.swing.JComponent;
|
||||
import java.awt.Graphics;
|
||||
|
||||
public class Ciel extends JComponent {
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
// obligatoire : si le composant n'est pas censé être transparent
|
||||
if (this.isOpaque()) {
|
||||
// obligatoire : on repeint toute la surface avec la couleur de fond
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
// maintenant on dessine ce que l'on veut
|
||||
secondPinceau.setColor(this.getForeground());
|
||||
secondPinceau.drawString("Bonjour !", 10, 20);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
createAndShowGUI();
|
||||
});
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
JFrame fenetre = new JFrame("Ciel Bleu");
|
||||
fenetre.setSize(400, 400);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
// Ajout de votre composant Ciel dans la fenêtre
|
||||
Ciel cielComponent = new Ciel();
|
||||
fenetre.add(cielComponent);
|
||||
|
||||
// Assurez-vous que la fenêtre est visible
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import javax.swing.JComponent;
|
||||
import java.awt.Graphics;
|
||||
|
||||
public class Soleil{
|
||||
|
||||
public Soleil(){
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
Main.java, SkyFrame.java et SunPanel.java on été générer par ChatGPT.
|
||||
|
||||
Le code n'est pas forcément bon, c'est juste pour voir comment faire
|
@ -0,0 +1,12 @@
|
||||
import javax.swing.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
SkyFrame skyFrame = new SkyFrame();
|
||||
skyFrame.setSize(800, 600);
|
||||
skyFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
skyFrame.setVisible(true);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class SkyFrame extends JFrame {
|
||||
private SunPanel sunPanel;
|
||||
|
||||
public SkyFrame() {
|
||||
setTitle("Sky with Sun");
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
sunPanel = new SunPanel();
|
||||
add(sunPanel, BorderLayout.CENTER);
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
sunPanel.increaseSunRadius(15);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class SunPanel extends JPanel {
|
||||
private int sunRadius;
|
||||
|
||||
public SunPanel() {
|
||||
sunRadius = 50; // Rayon initial du soleil
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
increaseSunRadius(15);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void increaseSunRadius(int increment) {
|
||||
sunRadius += increment;
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setColor(new Color(115, 194, 251)); // Couleur du ciel
|
||||
g2d.fillRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
int sunX = getWidth() / 2 - sunRadius;
|
||||
int sunY = getHeight() - sunRadius * 2;
|
||||
|
||||
g2d.setColor(Color.YELLOW); // Couleur du soleil
|
||||
g2d.fillOval(sunX, sunY, sunRadius * 2, sunRadius * 2);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user