This commit is contained in:
2024-03-18 13:54:22 +01:00
parent eb581c8a31
commit a28bef01d7
69 changed files with 855 additions and 5 deletions

Binary file not shown.

View File

@@ -0,0 +1,18 @@
public class Moto implements Vehicule{
private String type;
private int roues;
public Moto(){
this.type = "moto";
this.roues = 2;
}
public int nbRoues(){
return this.roues;
}
public String sorte(){
return this.type;
}
}

Binary file not shown.

View File

@@ -0,0 +1,22 @@
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.");
}
}

Binary file not shown.

View File

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

Binary file not shown.

View File

@@ -0,0 +1,19 @@
public class Voiture implements Vehicule{
private String type;
private int roues;
public Voiture(){
this.type = "voiture";
this.roues = 4;
}
public int nbRoues(){
return this.roues;
}
public String sorte(){
return this.type;
}
}