"depot M213"
This commit is contained in:
37
TD4/src/vehicule/Avion.java
Executable file
37
TD4/src/vehicule/Avion.java
Executable file
@ -0,0 +1,37 @@
|
||||
package vehicule;
|
||||
|
||||
public class Avion extends Vehicule {
|
||||
protected String moteur;
|
||||
protected int heuresVol;
|
||||
|
||||
public Avion() {
|
||||
moteur = "Moteur";
|
||||
heuresVol = 0;
|
||||
}
|
||||
|
||||
public Avion(String marque, int date, double prixac, String moteur, int heures) {
|
||||
this.moteur = moteur;
|
||||
heuresVol = heures;
|
||||
this.marque = marque;
|
||||
dateAchat = date;
|
||||
prixAchat = prixac;
|
||||
prixCourant = 0;
|
||||
}
|
||||
|
||||
public void calculePrix(int annee) {
|
||||
double pourcentage;
|
||||
if (moteur == "hélice") {
|
||||
pourcentage = 10*Math.floor(this.heuresVol/100);
|
||||
} else {
|
||||
pourcentage = 10* Math.floor(this.heuresVol/1000);
|
||||
}
|
||||
super.prixCourant = super.prixAchat - ((super.prixAchat/100) * pourcentage);
|
||||
if (super.prixCourant < 0) {
|
||||
super.prixCourant = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void affiche() {
|
||||
System.out.println(""+this.marque+" "+this.dateAchat+" "+this.prixAchat+" "+prixCourant+" "+this.moteur+" "+this.heuresVol);
|
||||
}
|
||||
}
|
29
TD4/src/vehicule/GestionVehicule.java
Executable file
29
TD4/src/vehicule/GestionVehicule.java
Executable file
@ -0,0 +1,29 @@
|
||||
package vehicule;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class GestionVehicule {
|
||||
private static int ANNEE_ACTUELLE = Calendar.getInstance().get(Calendar.YEAR);
|
||||
|
||||
public static void main(String[] args) {
|
||||
Voiture[] garage = new Voiture[3];
|
||||
Avion[] hangar = new Avion[2];
|
||||
|
||||
garage[0] = new Voiture("Peugeot", 2005, 13400.00, 1.4, 5, 4.0, 12000);
|
||||
garage[1] = new Voiture("Porsche", 2010, 160000.00, 3.6, 2, 25.0, 8320);
|
||||
garage[2] = new Voiture("Fiat", 1999, 8400.00, 1.2, 3, 5.0, 125000);
|
||||
|
||||
hangar[0] = new Avion("Cessna", 1979, 204739.90, "HELICES", 250);
|
||||
hangar[1] = new Avion("Gulfstream", 1993, 4321098.00, "REACTION", 1300);
|
||||
|
||||
for (int i = 0; i < garage.length; i++) {
|
||||
garage[i].calculePrix(ANNEE_ACTUELLE);
|
||||
garage[i].affiche();
|
||||
}
|
||||
|
||||
for (int i = 0; i < hangar.length; i++) {
|
||||
hangar[i].calculePrix(ANNEE_ACTUELLE);
|
||||
hangar[i].affiche();
|
||||
}
|
||||
}
|
||||
}
|
32
TD4/src/vehicule/Vehicule.java
Executable file
32
TD4/src/vehicule/Vehicule.java
Executable file
@ -0,0 +1,32 @@
|
||||
package vehicule;
|
||||
|
||||
public class Vehicule {
|
||||
protected String marque;
|
||||
protected int dateAchat;
|
||||
protected double prixAchat;
|
||||
protected double prixCourant;
|
||||
|
||||
public Vehicule() {
|
||||
marque = "";
|
||||
dateAchat = 0;
|
||||
prixAchat = 0;
|
||||
prixCourant = 0;
|
||||
}
|
||||
|
||||
public Vehicule(String s, int d, double pA) {
|
||||
this.marque = s;
|
||||
dateAchat = d;
|
||||
prixAchat = pA;
|
||||
prixCourant = 0;
|
||||
}
|
||||
|
||||
public void calculPrix(int y) {
|
||||
int previousY = this.dateAchat - y;
|
||||
this.prixCourant = this.prixAchat - ((this.prixAchat/100) * previousY);
|
||||
}
|
||||
|
||||
public void affiche() {
|
||||
System.out.println(""+this.marque+" "+this.dateAchat+" "+this.prixAchat+" "+prixCourant);
|
||||
}
|
||||
|
||||
}
|
58
TD4/src/vehicule/Voiture.java
Executable file
58
TD4/src/vehicule/Voiture.java
Executable file
@ -0,0 +1,58 @@
|
||||
package vehicule;
|
||||
|
||||
public class Voiture extends Vehicule {
|
||||
protected double cylindree;
|
||||
protected int nbPorte;
|
||||
protected double puissance;
|
||||
protected double kilometrage;
|
||||
|
||||
public Voiture() {
|
||||
cylindree = 0;
|
||||
nbPorte = 0;
|
||||
puissance = 0;
|
||||
kilometrage = 0;
|
||||
}
|
||||
|
||||
public Voiture(String marque, int date, double prixac, double cyl, int nbP, double pui, double kilo) {
|
||||
cylindree = cyl;
|
||||
nbPorte = nbP;
|
||||
puissance = pui;
|
||||
kilometrage = kilo;
|
||||
this.marque = marque;
|
||||
dateAchat = date;
|
||||
prixAchat = prixac;
|
||||
prixCourant = 0;
|
||||
}
|
||||
|
||||
|
||||
public void calculePrix(int annee) {
|
||||
int anneesPass = (annee - this.dateAchat)*2;
|
||||
double pourcentagekm = Math.floor(this.kilometrage/10000);
|
||||
boolean malus = false;
|
||||
boolean bonus = false;
|
||||
if (this.marque == "fiat" || this.marque == "renaud") {
|
||||
malus = true;
|
||||
} else if (this.marque == "ferrari" || this.marque == "mclaren") {
|
||||
bonus = true;
|
||||
}
|
||||
|
||||
this.prixCourant = this.prixAchat - ((this.prixAchat/100) * anneesPass);
|
||||
this.prixCourant -= ((this.prixAchat/100)*(pourcentagekm*5));
|
||||
if (malus)
|
||||
this.prixCourant -= (this.prixAchat/100)*10;
|
||||
|
||||
if (bonus)
|
||||
this.prixCourant += (this.prixAchat/100)*20;
|
||||
|
||||
if (this.prixCourant < 0) {
|
||||
this.prixCourant = 0;
|
||||
} else if (this.prixCourant > this.prixAchat) {
|
||||
this.prixCourant = this.prixAchat;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void affiche() {
|
||||
System.out.println("Marque : "+this.marque+" Date: "+this.dateAchat+" Prix d'achat "+this.prixAchat+" Prix Courant :"+this.prixCourant+" Cylindree "+this.cylindree+" Nb Portes "+this.nbPorte+" Puissance "+this.puissance+" Kilometrage "+this.kilometrage);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user