update
This commit is contained in:
BIN
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Moto.class
Normal file
BIN
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Moto.class
Normal file
Binary file not shown.
10
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Moto.java
Normal file
10
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Moto.java
Normal file
@@ -0,0 +1,10 @@
|
||||
public class Moto implements Vehicule{
|
||||
@Override
|
||||
public int nbRoues(){
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public String sorte(){
|
||||
return "bcaene";
|
||||
}
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Test.class
Normal file
BIN
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Test.class
Normal file
Binary file not shown.
22
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Test.java
Normal file
22
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Test.java
Normal 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.");
|
||||
}
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Vehicule.class
Normal file
BIN
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Vehicule.class
Normal file
Binary file not shown.
4
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Vehicule.java
Normal file
4
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Vehicule.java
Normal file
@@ -0,0 +1,4 @@
|
||||
public interface Vehicule{
|
||||
int nbRoues();
|
||||
String sorte();
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Voiture.class
Normal file
BIN
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Voiture.class
Normal file
Binary file not shown.
10
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Voiture.java
Normal file
10
DEV/DEV2.1/TP07_Polymorphisme/Q1_Vehicule/Voiture.java
Normal file
@@ -0,0 +1,10 @@
|
||||
public class Voiture implements Vehicule{
|
||||
@Override
|
||||
public int nbRoues(){
|
||||
return 4;
|
||||
}
|
||||
@Override
|
||||
public String sorte(){
|
||||
return "vuitore";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user