"depot M213"

This commit is contained in:
JunkJumper
2020-05-03 14:24:13 +02:00
parent 1408744dbb
commit e5983242c6
136 changed files with 161184 additions and 0 deletions

BIN
TD4/TD4.pdf Executable file

Binary file not shown.

View File

@ -0,0 +1,78 @@
package pointcolore;
import java.awt.Color;
import point.Point;
public class PointColore extends Point {
private Color couleur;
//==================================================
public Color getCouleur() {
return couleur;
}
public void setCouleur(Color couleur) {
this.couleur = couleur;
}
@Override
public String toString() {
return "Couleur = " + couleur + " --- Coords = " + super.toString();
}
//==================================================
public PointColore() {
this.setCouleur(Color.black);
}
public PointColore(double x, double y, Color c) {
super(x,y);
this.setCouleur(c);
}
public void colore(Color c){
this.setCouleur(c);
}
public boolean likeColor(PointColore pc) {
if(this.couleur == pc.couleur)
return true;
else return false;
}
@Override
public boolean equals (Object obj)
{
Point p = (Point)obj;
if (super.x == p.x && super.y == p.y)
return true;
else return false;
}
public PointColore projX()
{
Point p = super.projX();
return new PointColore(p.getX(), p.getY(), this.couleur);
}
public PointColore projY()
{
Point p = super.projY();
return new PointColore(p.getY(), p.getY(), this.couleur);
}
}

View File

@ -0,0 +1,30 @@
package pointcolore;
import java.awt.Color;
import point.Point;
public class TestPointColore {
public static void main(String[] args) {
Point Z = new Point(1., 8.);
PointColore A = new PointColore(3., 5., Color.black);
PointColore B = new PointColore(2.5, 8., Color.green);
PointColore C = new PointColore(1., -2., Color.red);
PointColore O = new PointColore(0., 0., Color.yellow);
PointColore I = new PointColore(1.0, 0.0, Color.yellow);
PointColore J = new PointColore(0.0, 1.0, Color.red);
System.out.println(" Z = " + Z.toString());
System.out.println(" O = " + O.toString());
System.out.println(" I = " + I.toString());
System.out.println(" J = " + J.toString());
System.out.println(" A = " + A.toString());
System.out.println(" B = " + B.toString());
System.out.println(" C = " + C.toString());
A.setCouleur(Color.white);
System.out.println(A.toString());
}
}

37
TD4/src/vehicule/Avion.java Executable file
View 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);
}
}

View 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
View 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
View 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);
}
}