This commit is contained in:
Emmanuel Srivastava
2025-03-03 21:48:22 +01:00
parent 7a4a32cdc9
commit dc3359eb92
7 changed files with 92 additions and 1 deletions

View File

@@ -17,7 +17,6 @@ public class MainSautoir {
}
}
frame.setSize(500,500);
frame.setLocation(500,250);

View File

@@ -0,0 +1,26 @@
import javax.swing.*;
import java.awt.*;
public class Acceuil extends JComponent {
private Image logo;
public Acceuil() {
super();
this.logo = Toolkit.getDefaultToolkit().getImage("img.png");
}
@Override
protected void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
secondPinceau.setColor(this.getForeground());
Font fonte = new Font("TimesRoman", Font.BOLD,24);
secondPinceau.setColor(new Color(128,0,128));
secondPinceau.setFont(fonte);
secondPinceau.drawString("IUT", 10, 20);
secondPinceau.drawImage(this.logo, 20,30, this);
}
}

View File

@@ -0,0 +1,14 @@
import javax.swing.*;
import java.awt.*;
public class MainAcceuil {
public static void main(String[] args) {
JFrame frame = new JFrame("Acceuil");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true); //https://waytolearnx.com/2020/05/changer-la-bordure-dune-jframe-java.html
frame.setSize(278,183);
frame.setLocation(500,250);
frame.setVisible(true);
}
}

View File

@@ -0,0 +1,12 @@
public class Moto implements Vehicule {
@Override
public int nbRoues() {
return 2;
}
@Override
public String sorte() {
return "Moto";
}
}

View File

@@ -0,0 +1,23 @@
import javax.swing.JOptionPane;
public class Test {
public static void main(String[] args) {
Vehicule v;
Object[] choix = {"Voiture", "Moto"};
int reponse = JOptionPane.showOptionDialog(null,
"Quel v\u00E9hicule choisissez-vous ?",
"Question",
JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
choix,
null);
if (reponse == 0)
v = new Voiture();
else
v = new Moto();
System.out.println("Une "+v.sorte()+" poss\u00E8de "+v.nbRoues()+" roues.");
}
}

View File

@@ -0,0 +1,5 @@
public interface Vehicule {
public int nbRoues();
public String sorte();
}

View File

@@ -0,0 +1,12 @@
public class Voiture implements Vehicule {
@Override
public String sorte() {
return "Voiture";
}
@Override
public int nbRoues() {
return 4;
}
}