Exercice 6, Partie 1.
This commit is contained in:
parent
a2d533ef49
commit
b2eaec0ef2
2 changed files with 26 additions and 0 deletions
|
@ -1,12 +1,14 @@
|
|||
package partie4;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
public class Voiture {
|
||||
int puissance = 10;
|
||||
double vitesse = 0;
|
||||
boolean estDemarre = false;
|
||||
String nom;
|
||||
Date dateCreation;
|
||||
|
||||
private static ArrayList<Voiture> listeVoitures = new ArrayList<Voiture>();
|
||||
|
||||
|
@ -35,6 +37,10 @@ public class Voiture {
|
|||
return this.estDemarre;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return this.dateCreation;
|
||||
}
|
||||
|
||||
public void setPuissance(int p) {
|
||||
this.puissance = p;
|
||||
}
|
||||
|
@ -64,4 +70,9 @@ public class Voiture {
|
|||
System.out.println("La vitesse(" + v + ") est supérieure à la puissance(" + this.puissance + ").");
|
||||
}
|
||||
}
|
||||
|
||||
public void setDate(Date d)
|
||||
{
|
||||
this.dateCreation = d;
|
||||
}
|
||||
}
|
||||
|
|
15
src/partie6/exercice6part1.java
Normal file
15
src/partie6/exercice6part1.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package partie6;
|
||||
import java.util.Date;
|
||||
|
||||
import partie4.Voiture;
|
||||
|
||||
public class exercice6part1 {
|
||||
public static void main(String[] args) {
|
||||
Voiture voiture1 = new Voiture(10);
|
||||
// Date 12/11(-1)/2020(-1900) -> Deprecated. Il vaut mieux utiliser la class Calendar.
|
||||
// Date sert visiblement à stocker une date au format Epoch directement.
|
||||
voiture1.setDate(new Date(120, 10, 12));
|
||||
System.out.println(voiture1.getDate().toString());
|
||||
// Print : Thu Nov 12 00:00:00 CET 2020
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue