tree and classes ok ! :D
This commit is contained in:
parent
91677806cf
commit
e675183ae8
@ -1,3 +1,5 @@
|
|||||||
|
package TD1;
|
||||||
|
|
||||||
public class HelloWorld
|
public class HelloWorld
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package point;
|
package TD1.point;
|
||||||
|
|
||||||
public class Point
|
public class Point
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package point;
|
package TD1.point;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package point;
|
package TD1.point;
|
||||||
|
|
||||||
public class TestPoint {
|
public class TestPoint {
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package input;
|
package TD10.input;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
package input;
|
package TD10.input;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class LectureFichierEcriture {
|
public class LectureFichierEcriture {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package input;
|
package TD10.input;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD10.pokemon;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.lang.Math;
|
import java.lang.Math;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD10.pokemon;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD10.pokemon;
|
||||||
|
|
||||||
public abstract class Pokemon implements Comparable<Pokemon> {
|
public abstract class Pokemon implements Comparable<Pokemon> {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD10.pokemon;
|
||||||
|
|
||||||
public class PokemonEAU extends Pokemon{
|
public class PokemonEAU extends Pokemon{
|
||||||
private int nb_nageoires;
|
private int nb_nageoires;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD10.pokemon;
|
||||||
|
|
||||||
public class PokemonELECTRIK extends Pokemon {
|
public class PokemonELECTRIK extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD10.pokemon;
|
||||||
|
|
||||||
public class PokemonFEU extends Pokemon {
|
public class PokemonFEU extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD10.pokemon;
|
||||||
|
|
||||||
public class PokemonPLANTE extends Pokemon{
|
public class PokemonPLANTE extends Pokemon{
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD10.pokemon;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD10.pokemon;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ensembleEntierBorne;
|
package TD2.ensembleEntierBorne;
|
||||||
|
|
||||||
public class EnsembleEntierBorne {
|
public class EnsembleEntierBorne {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ensembleEntierBorne;
|
package TD2.ensembleEntierBorne;
|
||||||
|
|
||||||
public class TestEnsembleEntierBorne {
|
public class TestEnsembleEntierBorne {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package tripletEntier;
|
package TD2.tripletEntier;
|
||||||
|
|
||||||
public class TestTripletEntier
|
public class TestTripletEntier
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package tripletEntier;
|
package TD2.tripletEntier;
|
||||||
|
|
||||||
public class TripletEntier {
|
public class TripletEntier {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package boite;
|
package TD3.boite;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package boite;
|
package TD3.boite;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package boite;
|
package TD3.boite;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fleuriste;
|
package TD3.fleuriste;
|
||||||
|
|
||||||
public class Bouquet {
|
public class Bouquet {
|
||||||
private LotFleurs lot1;
|
private LotFleurs lot1;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fleuriste;
|
package TD3.fleuriste;
|
||||||
|
|
||||||
public class Fleur {
|
public class Fleur {
|
||||||
String nom;
|
String nom;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fleuriste;
|
package TD3.fleuriste;
|
||||||
|
|
||||||
public class LotFleur {
|
public class LotFleur {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fleuriste;
|
package TD3.fleuriste;
|
||||||
|
|
||||||
public class LotFleurs {
|
public class LotFleurs {
|
||||||
Fleur fleur;
|
Fleur fleur;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fleuriste;
|
package TD3.fleuriste;
|
||||||
|
|
||||||
public class Stock {
|
public class Stock {
|
||||||
Fleur roses;
|
Fleur roses;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fleuriste;
|
package TD3.fleuriste;
|
||||||
|
|
||||||
public class TestBouquet {
|
public class TestBouquet {
|
||||||
public static void main( String[] args) {
|
public static void main( String[] args) {
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
package segment;
|
|
||||||
import point.Point;
|
|
||||||
|
|
||||||
public class Segment {
|
|
||||||
|
|
||||||
public Point origine;
|
|
||||||
public Point extremite;
|
|
||||||
|
|
||||||
public Segment(Point p1, Point p2) throws Throwable
|
|
||||||
{
|
|
||||||
if(p1.equals(p2)) throw new Throwable("Les points sont confondus !");
|
|
||||||
this.origine = p1;
|
|
||||||
this.extremite = p2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object B)
|
|
||||||
{
|
|
||||||
Segment s = (Segment) B;
|
|
||||||
return this.origine.equals(s.origine)&&(this.extremite.equals(s.extremite)) || this.origine.equals(extremite)&&(this.extremite.equals(s.origine));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "[" + origine + " - " + extremite + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public Object clone() throws Throwable
|
|
||||||
{
|
|
||||||
return new Segment((Point)this.origine.clone, (Point)this.extremite.clone);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public double longueur()
|
|
||||||
{
|
|
||||||
return origine.getDistance(extremite);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Segment projX() throws Throwable
|
|
||||||
{
|
|
||||||
if(origine.projX().equals(extremite.projX())) throw new Throwable("Les points projetes sont confondus !");
|
|
||||||
return new Segment(origine.projX(), extremite.projX());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Segment projY() throws Throwable
|
|
||||||
{
|
|
||||||
if(origine.projY().equals(extremite.projY())) throw new Throwable("Les points projetes sont confondus !");
|
|
||||||
return new Segment(origine.projY(), extremite.projY());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package segment;
|
|
||||||
import point.Point;
|
|
||||||
|
|
||||||
public class TestSegment {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
Point O = new Point();
|
|
||||||
Point I = new Point(1.0, 0.0);
|
|
||||||
Point J = new Point(0.0, 1.0);
|
|
||||||
Point A = new Point(1.0, 3.5);
|
|
||||||
Point B = new Point(8.0, 20.0);
|
|
||||||
Point C = new Point(-2.0, 3.0);
|
|
||||||
Point D = new Point(1.0, 1.0);
|
|
||||||
|
|
||||||
Segment AB = null;
|
|
||||||
Segment BC = null;
|
|
||||||
Segment OI = null;
|
|
||||||
Segment OJ = null;
|
|
||||||
Segment OD = null;
|
|
||||||
//Segment AA = null;
|
|
||||||
try {
|
|
||||||
AB = new Segment(A, B);
|
|
||||||
BC = new Segment(B, C);
|
|
||||||
OI = new Segment(O, I);
|
|
||||||
OJ = new Segment(O, J);
|
|
||||||
OD = new Segment(O, D);
|
|
||||||
//AA = new Segment(A, A);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
System.out.println("Erreur : " + t);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println(OI.toString());
|
|
||||||
System.out.println(OJ.toString());
|
|
||||||
System.out.println(AB.toString());
|
|
||||||
System.out.println(BC.toString());
|
|
||||||
System.out.println(OD.toString());
|
|
||||||
//System.out.println(AA.toString());
|
|
||||||
|
|
||||||
System.out.println("Hello world !");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package segments;
|
|
||||||
|
|
||||||
import Coords.Coords;
|
|
||||||
|
|
||||||
public class Segment {
|
|
||||||
private Coords origine;
|
|
||||||
private Coords extremite;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Segment(Coords debut, Coords fin) throws RuntimeException {
|
|
||||||
if (debut.equals(fin) == true)
|
|
||||||
throw new RuntimeException("Points confondus");
|
|
||||||
origine = new Coords(debut);
|
|
||||||
extremite = new Coords(fin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Coords getOrigine() {
|
|
||||||
return this.origine;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Coords getExtremite() {
|
|
||||||
return this.extremite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double length() {
|
|
||||||
return this.origine.getDistance(this.extremite);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Segment projX() {
|
|
||||||
Segment projetX = new Segment(this.origine.projx(), this.extremite.projx());
|
|
||||||
return projetX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Segment projY() {
|
|
||||||
Segment projetY = new Segment(this.origine.projY(), this.extremite.projY());
|
|
||||||
return projetY;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean equals(Segment deux) {
|
|
||||||
if (this.origine.equals(deux.origine) && this.extremite.equals(deux.extremite)) {
|
|
||||||
return true;
|
|
||||||
} else if (this.origine.equals(deux.extremite) && this.extremite.equals(deux.origine)){
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Segment clone() {
|
|
||||||
Segment clonage = new Segment(this.origine, this.extremite);
|
|
||||||
return clonage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return "Le point d'origine à pour coordonnées "+this.origine.toString()+" et le point d'extremite à pour coordonnées "+this.extremite.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
|||||||
package segments;
|
|
||||||
|
|
||||||
import Coords.Coords;
|
|
||||||
|
|
||||||
public class TestSegment {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Coords p11 = new Coords(12.2, 8.3);
|
|
||||||
Coords p12 = new Coords(21.1, 6.5);
|
|
||||||
Coords p32 = new Coords(45.5, 8.6);
|
|
||||||
Segment s1 = new Segment(p11, p12);
|
|
||||||
Segment s2 = s1.clone();
|
|
||||||
Segment s3 = null;
|
|
||||||
try {
|
|
||||||
s3 = new Segment(p11, new Coords(45.5, 8.6));
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
e.getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
assert (s1.equals(s2) == true);
|
|
||||||
assert (s1.equals(s3) == false);
|
|
||||||
assert (s3.getExtremite().equals(p32) == true);
|
|
||||||
assert (s3.length() == 33.30135);
|
|
||||||
|
|
||||||
assert (s3.projX().equals(new Segment(p11.projx(), p32.projx())));
|
|
||||||
//Segment err = new Segment(p11, p11);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("fin du programme");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
package pointcolore;
|
package TD4.pointcolore;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import point.Point;
|
import TD1.point.Point;
|
||||||
|
|
||||||
public class PointColore extends Point {
|
public class PointColore extends Point {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package pointcolore;
|
package TD4.pointcolore;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import point.Point;
|
import TD1.point.Point;
|
||||||
|
|
||||||
public class TestPointColore {
|
public class TestPointColore {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package vehicule;
|
package TD4.vehicule;
|
||||||
|
|
||||||
public class Avion extends Vehicule {
|
public class Avion extends Vehicule {
|
||||||
protected String moteur;
|
protected String moteur;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package vehicule;
|
package TD4.vehicule;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package vehicule;
|
package TD4.vehicule;
|
||||||
|
|
||||||
public class Vehicule {
|
public class Vehicule {
|
||||||
protected String marque;
|
protected String marque;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package vehicule;
|
package TD4.vehicule;
|
||||||
|
|
||||||
public class Voiture extends Vehicule {
|
public class Voiture extends Vehicule {
|
||||||
protected double cylindree;
|
protected double cylindree;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package pointcolore;
|
package TD5.pointcolore;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import point.Point;
|
import TD1.point.Point;
|
||||||
|
|
||||||
public class PointColore extends Point {
|
public class PointColore extends Point {
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package pointcolore;
|
package TD5.pointcolore;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import TD1.point.Point;
|
||||||
import point.Point;
|
|
||||||
|
|
||||||
public class TestPointColore {
|
public class TestPointColore {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD5.pokemon;
|
||||||
|
|
||||||
public class Pokemon {
|
public class Pokemon {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD5.pokemon;
|
||||||
|
|
||||||
public class PokemonEAU extends Pokemon{
|
public class PokemonEAU extends Pokemon{
|
||||||
private int nb_nageoires;
|
private int nb_nageoires;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD5.pokemon;
|
||||||
|
|
||||||
public class PokemonELECTRIK extends Pokemon {
|
public class PokemonELECTRIK extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD5.pokemon;
|
||||||
|
|
||||||
public class PokemonFEU extends Pokemon {
|
public class PokemonFEU extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD5.pokemon;
|
||||||
|
|
||||||
public class PokemonPLANTE extends Pokemon{
|
public class PokemonPLANTE extends Pokemon{
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD5.pokemon;
|
||||||
|
|
||||||
public class TestPokemon {
|
public class TestPokemon {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD5.pokemon;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
package pkmA;
|
|
||||||
|
|
||||||
public interface Attaque {
|
|
||||||
public void attaquer(Object adv);
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
package pkmA;
|
|
||||||
|
|
||||||
public abstract class Pokemon{
|
|
||||||
private String nom;
|
|
||||||
private double taille;
|
|
||||||
private double poids;
|
|
||||||
private int pv;
|
|
||||||
private int pc;
|
|
||||||
Type type;
|
|
||||||
|
|
||||||
public Pokemon() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pokemon(String nom, double taille, double poids, int pv, int pc, Type type) {
|
|
||||||
if (type != Type.ELECTRIK && type != Type.EAU && type != Type.FEU && type != Type.PLANTE)
|
|
||||||
throw new RuntimeException("Ce type : "+type.getDescription()+" n'existe pas");
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.nom = nom;
|
|
||||||
this.taille = taille;
|
|
||||||
this.poids = poids;
|
|
||||||
this.pv = pv;
|
|
||||||
this.pc = pc;
|
|
||||||
this.type = type;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNom() {
|
|
||||||
return nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTaille() {
|
|
||||||
return taille;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPoids() {
|
|
||||||
return poids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPv() {
|
|
||||||
return pv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPc() {
|
|
||||||
return pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void changePv(int modif);
|
|
||||||
|
|
||||||
public abstract void attaquer(Pokemon adv);
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
package pkmA;
|
|
||||||
|
|
||||||
public class PokemonEAU extends Pokemon{
|
|
||||||
private String nom;
|
|
||||||
private double taille; // en m
|
|
||||||
private double poids; // en kg
|
|
||||||
private int pv;
|
|
||||||
private int pc;
|
|
||||||
Type type;
|
|
||||||
private int nb_nageoires;
|
|
||||||
|
|
||||||
public PokemonEAU() {
|
|
||||||
type = Type.EAU;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PokemonEAU(String n, double t, double p, int v, int c, int g) {
|
|
||||||
super(n, t, p, v, c, Type.EAU);
|
|
||||||
this.nom = n;
|
|
||||||
this.type = Type.EAU;
|
|
||||||
nb_nageoires = g;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNom() {
|
|
||||||
return nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTaille() {
|
|
||||||
return taille;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPoids() {
|
|
||||||
return poids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPv() {
|
|
||||||
return pv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPc() {
|
|
||||||
return pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNb_nageoires() {
|
|
||||||
return nb_nageoires;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changePv(int modif) {
|
|
||||||
pv = Math.max(0, pv-modif);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double calculerVitesse() {
|
|
||||||
return (this.poids*nb_nageoires)/25.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void attaquer(Pokemon adv) {
|
|
||||||
if (adv.getType() == Type.EAU || adv.getType() == Type.PLANTE) {
|
|
||||||
adv.changePv(Math.round(super.getPc()/2));
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
|
||||||
} else if (adv.getType() == Type.ELECTRIK) {
|
|
||||||
adv.changePv(super.getPc());
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
|
||||||
} else {
|
|
||||||
adv.changePv(2*super.getPc());
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+2*pc+" a "+adv.getNom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return "Pokemon "+super.getNom()+" de type "+type.getDescription()+" ("+super.getPoids()+" kg, "+super.getTaille()+" m, "+super.getPv()+" pts de vie, "+super.getPc()+" force de combat), "+nb_nageoires+" nageoires)";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
package pkmA;
|
|
||||||
|
|
||||||
public class PokemonELECTRIK extends Pokemon{
|
|
||||||
private String nom;
|
|
||||||
private double taille; // en m
|
|
||||||
private double poids; // en kg
|
|
||||||
private int pv;
|
|
||||||
private int pc;
|
|
||||||
Type type;
|
|
||||||
private int nb_pattes;
|
|
||||||
private int nb_ailes;
|
|
||||||
private double intensite;
|
|
||||||
|
|
||||||
public PokemonELECTRIK() {
|
|
||||||
type = Type.ELECTRIK;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PokemonELECTRIK(String n, double t, double p, int v, int c, int g, int a, double i) {
|
|
||||||
super(n, t, p, v, c, Type.ELECTRIK);
|
|
||||||
this.nom = n;
|
|
||||||
this.type = Type.ELECTRIK;
|
|
||||||
nb_pattes = g;
|
|
||||||
nb_ailes = a;
|
|
||||||
intensite = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNom() {
|
|
||||||
return nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTaille() {
|
|
||||||
return taille;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPoids() {
|
|
||||||
return poids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPv() {
|
|
||||||
return pv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPc() {
|
|
||||||
return pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPattes() {
|
|
||||||
return nb_pattes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAiles() {
|
|
||||||
return nb_ailes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getIntensite() {
|
|
||||||
return intensite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changePv(int modif) {
|
|
||||||
pv = Math.max(0, pv-modif);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double calculerVitesse() {
|
|
||||||
return (nb_ailes+nb_pattes) * intensite * 0.05;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void attaquer(Pokemon adv) {
|
|
||||||
if (adv.getType() == Type.ELECTRIK || adv.getType() == Type.PLANTE) {
|
|
||||||
adv.changePv(Math.round(super.getPc()/2));
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
|
||||||
} else if (adv.getType() == Type.FEU) {
|
|
||||||
adv.changePv(super.getPc());
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
|
||||||
} else {
|
|
||||||
adv.changePv(2*super.getPc());
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return "Pokemon "+super.getNom()+" de type "+type.getDescription()+" ("+super.getPoids()+" kg, "+super.getTaille()+" m, "+super.getPv()+" pts de vie, "+super.getPc()+" force de combat), "+nb_pattes+" pattes, "+nb_ailes+" ailes, "+intensite+" mA)";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
package pkmA;
|
|
||||||
|
|
||||||
public class PokemonFEU extends Pokemon{
|
|
||||||
private String nom;
|
|
||||||
private double taille; // en m
|
|
||||||
private double poids; // en kg
|
|
||||||
private int pv;
|
|
||||||
private int pc;
|
|
||||||
Type type;
|
|
||||||
private int nb_pattes;
|
|
||||||
|
|
||||||
public PokemonFEU() {
|
|
||||||
type = Type.FEU;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PokemonFEU(String n, double t, double p, int v, int c, int g) {
|
|
||||||
super(n, t, p, v, c, Type.FEU);
|
|
||||||
this.nom = n;
|
|
||||||
this.type = Type.FEU;
|
|
||||||
nb_pattes = g;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNom() {
|
|
||||||
return nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTaille() {
|
|
||||||
return taille;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPoids() {
|
|
||||||
return poids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPv() {
|
|
||||||
return pv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPc() {
|
|
||||||
return pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPattes() {
|
|
||||||
return nb_pattes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changePv(int modif) {
|
|
||||||
pv = Math.max(0, pv-modif);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double calculerVitesse() {
|
|
||||||
return this.getPoids()*nb_pattes* 0.03;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void attaquer(Pokemon adv) {
|
|
||||||
if (adv.getType() == Type.EAU || adv.getType() == Type.ELECTRIK) {
|
|
||||||
adv.changePv(Math.round(super.getPc()/2));
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
|
||||||
} else if (adv.getType() == Type.FEU) {
|
|
||||||
adv.changePv(super.getPc());
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
|
||||||
} else {
|
|
||||||
adv.changePv(2*super.getPc());
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+2*super.getPc()+" a "+adv.getNom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return "Pokemon "+super.getNom()+" de type "+type.getDescription()+" ("+super.getPoids()+" kg, "+super.getTaille()+" m, "+super.getPv()+" pts de vie, "+super.getPc()+" force de combat), "+nb_pattes+" pattes)";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
package pkmA;
|
|
||||||
|
|
||||||
public class PokemonPLANTE extends Pokemon{
|
|
||||||
private String nom;
|
|
||||||
private double taille; // en m
|
|
||||||
private double poids; // en kg
|
|
||||||
private int pv;
|
|
||||||
private int pc;
|
|
||||||
Type type;
|
|
||||||
|
|
||||||
public PokemonPLANTE() {
|
|
||||||
type = Type.PLANTE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PokemonPLANTE(String n, double t, double p, int v, int c) {
|
|
||||||
super(n, t, p, v, c, Type.PLANTE);
|
|
||||||
this.nom = n;
|
|
||||||
this.type = Type.PLANTE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNom() {
|
|
||||||
return nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTaille() {
|
|
||||||
return taille;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPoids() {
|
|
||||||
return poids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPv() {
|
|
||||||
return pv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPc() {
|
|
||||||
return pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changePv(int modif) {
|
|
||||||
pv = Math.max(0, pv-modif);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double calculerVitesse() {
|
|
||||||
return 10.0 / (this.getPoids()*this.getTaille());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void attaquer(Pokemon adv) {
|
|
||||||
if (adv.getType() == Type.FEU || adv.getType() == Type.PLANTE) {
|
|
||||||
adv.changePv(Math.round(super.getPc()/2));
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
|
||||||
} else if (adv.getType() == Type.EAU) {
|
|
||||||
adv.changePv(super.getPc());
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
|
||||||
} else {
|
|
||||||
adv.changePv(2*super.getPc());
|
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+2*super.getPc()+" a "+adv.getNom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return "Pokemon "+super.getNom()+" de type "+type.getDescription()+" ("+super.getPoids()+" kg, "+super.getTaille()+" m, "+super.getPv()+" pts de vie, "+super.getPc()+" force de combat),";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package pkmA;
|
|
||||||
|
|
||||||
|
|
||||||
public class TestPokemon {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Pokemon pikachu = new PokemonELECTRIK("Pikachu", 0.9, 5.3, 90, 50, 4, 0, 12);
|
|
||||||
Pokemon aquali = new PokemonEAU("Aquali", 2.1, 56.3, 140, 90, 3);
|
|
||||||
|
|
||||||
pikachu.attaquer(aquali);
|
|
||||||
assert aquali.getPv() == 40;
|
|
||||||
|
|
||||||
PokemonELECTRIK voltali = new PokemonELECTRIK("Voltali", 1.8, 47.3, 120, 130, 4, 0, 12);
|
|
||||||
PokemonPLANTE phylali = new PokemonPLANTE("Phylali", 1.6, 28.5, 130, 70);
|
|
||||||
Pokemon phyl = phylali;
|
|
||||||
|
|
||||||
phylali.attaquer(voltali);
|
|
||||||
|
|
||||||
aquali.attaquer(phyl);
|
|
||||||
System.out.println(voltali.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package pkmA;
|
|
||||||
|
|
||||||
enum Type {
|
|
||||||
EAU ("EAU"),
|
|
||||||
ELECTRIK ("ELECTRIK"),
|
|
||||||
FEU ("FEU"),
|
|
||||||
PLANTE ("PLANTE");
|
|
||||||
Type(String s){description = s;}
|
|
||||||
private String description;
|
|
||||||
public String getDescription() {return description;}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD6.pokemon;
|
||||||
|
|
||||||
public abstract class Pokemon {
|
public abstract class Pokemon {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD6.pokemon;
|
||||||
|
|
||||||
public class PokemonEAU extends Pokemon{
|
public class PokemonEAU extends Pokemon{
|
||||||
private int nb_nageoires;
|
private int nb_nageoires;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD6.pokemon;
|
||||||
|
|
||||||
public class PokemonELECTRIK extends Pokemon {
|
public class PokemonELECTRIK extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD6.pokemon;
|
||||||
|
|
||||||
public class PokemonFEU extends Pokemon {
|
public class PokemonFEU extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD6.pokemon;
|
||||||
|
|
||||||
public class PokemonPLANTE extends Pokemon{
|
public class PokemonPLANTE extends Pokemon{
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD6.pokemon;
|
||||||
|
|
||||||
public class TestPokemon {
|
public class TestPokemon {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD6.pokemon;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
|
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package vehiculev2;
|
package TD6.vehicule;
|
||||||
|
|
||||||
public class Camion extends VehiculeAMoteur {
|
public class Camion extends VehiculeAMoteur {
|
||||||
|
|
@ -1,29 +1,18 @@
|
|||||||
package vehicule;
|
package TD6.vehicule;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
public class GestionVehicule {
|
public class GestionVehicule {
|
||||||
private static int ANNEE_ACTUELLE = Calendar.getInstance().get(Calendar.YEAR);
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main (String [] args) {
|
||||||
Voiture[] garage = new Voiture[3];
|
Vehicule v1 = new Velo (17); // nb vitesses
|
||||||
Avion[] hangar = new Avion[2];
|
Vehicule v2 = new Voiture (40.5, 5); // capacité réservoir, nb Places
|
||||||
|
Vehicule v3 = new Camion (100.0, 100.0); // capacité réservoir, volume
|
||||||
garage[0] = new Voiture("Peugeot", 2005, 13400.00, 1.4, 5, 4.0, 12000);
|
System.out.println ("Vehicules : "+"\n" +v1 +"\n" +v2 +"\n" +v3 +"\n");
|
||||||
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);
|
* v2.approvisionner (35.0) ; // litres d’essence v3.approvisionner (70.0);
|
||||||
|
* v1.transporter ("Dijon ", "Valence ") ; v2.transporter (5, 300) ;
|
||||||
hangar[0] = new Avion("Cessna", 1979, 204739.90, "HELICES", 250);
|
* v3.transporter (" des tuiles", 1000) ; }
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,32 +1,72 @@
|
|||||||
package vehicule;
|
package TD6.vehicule;
|
||||||
|
|
||||||
public abstract class Vehicule {
|
public abstract class Vehicule {
|
||||||
protected String marque;
|
|
||||||
protected int dateAchat;
|
private static int compteur = 0;
|
||||||
protected double prixAchat;
|
private int id;
|
||||||
protected double prixCourant;
|
private double distance;
|
||||||
|
|
||||||
|
/*==========================================================Getter & Setters====================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the compteur
|
||||||
|
*/
|
||||||
|
public static int getCompteur() {
|
||||||
|
return compteur;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the distance
|
||||||
|
*/
|
||||||
|
public double getDistance() {
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param distance the distance to set
|
||||||
|
*/
|
||||||
|
public void setDistance(int distance) {
|
||||||
|
this.distance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id the id to set
|
||||||
|
*/
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param compteur the compteur to set
|
||||||
|
*/
|
||||||
|
public static void setCompteur(int compteur) {
|
||||||
|
Vehicule.compteur = compteur;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================================================================================*/
|
||||||
|
|
||||||
public Vehicule() {
|
public Vehicule() {
|
||||||
marque = "";
|
this.id = compteur;
|
||||||
dateAchat = 0;
|
compteur++;
|
||||||
prixAchat = 0;
|
distance = 0.;
|
||||||
prixCourant = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vehicule(String s, int d, double pA) {
|
@Override
|
||||||
this.marque = s;
|
public String toString() {
|
||||||
dateAchat = d;
|
return "Le véhicule Numéro " + id + " a parcourru " + distance;
|
||||||
prixAchat = pA;
|
|
||||||
prixCourant = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculPrix(int y) {
|
void rouler(double d) {
|
||||||
int previousY = this.dateAchat - y;
|
this.distance = d;
|
||||||
this.prixCourant = this.prixAchat - ((this.prixAchat/100) * previousY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void affiche() {
|
|
||||||
System.out.println(""+this.marque+" "+this.dateAchat+" "+this.prixAchat+" "+prixCourant);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package vehiculev2;
|
package TD6.vehicule;
|
||||||
|
|
||||||
public abstract class VehiculeAMoteur extends Vehicule {
|
public abstract class VehiculeAMoteur extends Vehicule {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package vehiculev2;
|
package TD6.vehicule;
|
||||||
|
|
||||||
public abstract class VehiculeSansMoteur extends Vehicule {
|
public abstract class VehiculeSansMoteur extends Vehicule {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package vehiculev2;
|
package TD6.vehicule;
|
||||||
|
|
||||||
public class Velo extends VehiculeSansMoteur{
|
public class Velo extends VehiculeSansMoteur{
|
||||||
|
|
@ -1,58 +1,32 @@
|
|||||||
package vehicule;
|
package TD6.vehicule;
|
||||||
|
|
||||||
public class Voiture extends Vehicule {
|
public class Voiture extends VehiculeAMoteur {
|
||||||
protected double cylindree;
|
|
||||||
protected int nbPorte;
|
|
||||||
protected double puissance;
|
|
||||||
protected double kilometrage;
|
|
||||||
|
|
||||||
public Voiture() {
|
private int nombrePlace;
|
||||||
cylindree = 0;
|
|
||||||
nbPorte = 0;
|
|
||||||
puissance = 0;
|
/*==========================================================Getter & Setters====================================================================*/
|
||||||
kilometrage = 0;
|
/**
|
||||||
|
* @return the nombrePlace
|
||||||
|
*/
|
||||||
|
public int getNombrePlace() {
|
||||||
|
return nombrePlace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Voiture(String marque, int date, double prixac, double cyl, int nbP, double pui, double kilo) {
|
/**
|
||||||
cylindree = cyl;
|
* @param nombrePlace the nombrePlace to set
|
||||||
nbPorte = nbP;
|
*/
|
||||||
puissance = pui;
|
public void setNombrePlace(int nombrePlace) {
|
||||||
kilometrage = kilo;
|
this.nombrePlace = nombrePlace;
|
||||||
this.marque = marque;
|
}
|
||||||
dateAchat = date;
|
/*==========================================================Getter & Setters====================================================================*/
|
||||||
prixAchat = prixac;
|
|
||||||
prixCourant = 0;
|
public Voiture(double c, int nb) {
|
||||||
|
super(c);
|
||||||
|
this.nombrePlace = nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
public void calculePrix(int annee) {
|
return super.toString() + " et " + this.nombrePlace + "places dans la voiture.";
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package vehiculev2;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
public class GestionVehicule {
|
|
||||||
|
|
||||||
public static void main (String [] args) {
|
|
||||||
Vehicule v1 = new Velo (17); // nb vitesses
|
|
||||||
Vehicule v2 = new Voiture (40.5, 5); // capacité réservoir, nb Places
|
|
||||||
Vehicule v3 = new Camion (100.0, 100.0); // capacité réservoir, volume
|
|
||||||
System.out.println ("Vehicules : "+"\n" +v1 +"\n" +v2 +"\n" +v3 +"\n");
|
|
||||||
/*
|
|
||||||
* v2.approvisionner (35.0) ; // litres d’essence v3.approvisionner (70.0);
|
|
||||||
* v1.transporter ("Dijon ", "Valence ") ; v2.transporter (5, 300) ;
|
|
||||||
* v3.transporter (" des tuiles", 1000) ; }
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
package vehiculev2;
|
|
||||||
|
|
||||||
public abstract class Vehicule {
|
|
||||||
|
|
||||||
private static int compteur = 0;
|
|
||||||
private int id;
|
|
||||||
private double distance;
|
|
||||||
|
|
||||||
/*==========================================================Getter & Setters====================================================================*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the compteur
|
|
||||||
*/
|
|
||||||
public static int getCompteur() {
|
|
||||||
return compteur;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the distance
|
|
||||||
*/
|
|
||||||
public double getDistance() {
|
|
||||||
return distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param distance the distance to set
|
|
||||||
*/
|
|
||||||
public void setDistance(int distance) {
|
|
||||||
this.distance = distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the id
|
|
||||||
*/
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id the id to set
|
|
||||||
*/
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param compteur the compteur to set
|
|
||||||
*/
|
|
||||||
public static void setCompteur(int compteur) {
|
|
||||||
Vehicule.compteur = compteur;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==============================================================================================================================================*/
|
|
||||||
|
|
||||||
public Vehicule() {
|
|
||||||
this.id = compteur;
|
|
||||||
compteur++;
|
|
||||||
distance = 0.;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Le véhicule Numéro " + id + " a parcourru " + distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void rouler(double d) {
|
|
||||||
this.distance = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package vehiculev2;
|
|
||||||
|
|
||||||
public class Voiture extends VehiculeAMoteur {
|
|
||||||
|
|
||||||
private int nombrePlace;
|
|
||||||
|
|
||||||
|
|
||||||
/*==========================================================Getter & Setters====================================================================*/
|
|
||||||
/**
|
|
||||||
* @return the nombrePlace
|
|
||||||
*/
|
|
||||||
public int getNombrePlace() {
|
|
||||||
return nombrePlace;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param nombrePlace the nombrePlace to set
|
|
||||||
*/
|
|
||||||
public void setNombrePlace(int nombrePlace) {
|
|
||||||
this.nombrePlace = nombrePlace;
|
|
||||||
}
|
|
||||||
/*==========================================================Getter & Setters====================================================================*/
|
|
||||||
|
|
||||||
public Voiture(double c, int nb) {
|
|
||||||
super(c);
|
|
||||||
this.nombrePlace = nb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return super.toString() + " et " + this.nombrePlace + "places dans la voiture.";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package ip;
|
package TD7.ip;
|
||||||
|
|
||||||
public class IP {
|
public class IP {
|
||||||
private String ip;
|
private String ip;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ip;
|
package TD7.ip;
|
||||||
|
|
||||||
public class MainIp {
|
public class MainIp {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package monney;
|
package TD7.monney;
|
||||||
|
|
||||||
public class Monnaie {
|
public class Monnaie {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package premierTest;
|
package TD7.premierTests;
|
||||||
|
|
||||||
public class MaClasse {
|
public class MaClasse {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package premierTest;
|
package TD7.premierTests;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
@ -1,5 +1,5 @@
|
|||||||
package parking;
|
package TD8.parking;
|
||||||
import vehicule.Voiture;
|
import TD6.vehicule.Voiture;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Parking {
|
public class Parking {
|
||||||
@ -16,7 +16,7 @@ public class Parking {
|
|||||||
if(parking.get(place)==null) {
|
if(parking.get(place)==null) {
|
||||||
parking.put(place, v);
|
parking.put(place, v);
|
||||||
}else {
|
}else {
|
||||||
throw new IllegalStateException("Place occupé");
|
throw new IllegalStateException("Place occup<EFBFBD>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Voiture liberer(int place) throws IndexOutOfBoundsException{
|
public Voiture liberer(int place) throws IndexOutOfBoundsException{
|
||||||
@ -25,14 +25,14 @@ public class Parking {
|
|||||||
return voit;
|
return voit;
|
||||||
}
|
}
|
||||||
public int chercher(Voiture v) throws IllegalStateException {
|
public int chercher(Voiture v) throws IllegalStateException {
|
||||||
for (int i = 0; i < parking.size(); i++) {
|
for (int i = 0; i < parking.size();) {
|
||||||
if(parking.get(i).equals(v)) {
|
if(parking.get(i).equals(v)) {
|
||||||
return i;
|
return i;
|
||||||
}else {
|
}else {
|
||||||
throw new IllegalStateException("Place inexistante");
|
throw new IllegalStateException("Place inexistante");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Voiture non présente");
|
System.out.println("Voiture non pr<EFBFBD>sente");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package parking;
|
package TD8.parking;
|
||||||
|
|
||||||
|
/*
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import vehicule.Voiture;
|
import TD6.vehicule.Voiture;
|
||||||
|
*/
|
||||||
|
|
||||||
public class ParkingTest {
|
public class ParkingTest {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
HashMap<Integer, Voiture> carpark = new HashMap<Integer, Voiture>();
|
/*HashMap<Integer, Voiture> carpark = new HashMap<Integer, Voiture>();
|
||||||
Voiture v1 = new Voiture("Peugeot", 2005, 13400.00, 1.4, 5, 4.0, 12000);
|
Voiture v1 = new Voiture("Peugeot", 2005, 13400.00, 1.4, 5, 4.0, 12000);
|
||||||
Voiture v2 = new Voiture("Porsche", 2010, 160000.00, 3.6, 2, 25.0, 8320);
|
Voiture v2 = new Voiture("Porsche", 2010, 160000.00, 3.6, 2, 25.0, 8320);
|
||||||
Voiture v3 = new Voiture("Fiat", 1999, 8400.00, 1.2, 3, 5.0, 125000);
|
Voiture v3 = new Voiture("Fiat", 1999, 8400.00, 1.2, 3, 5.0, 125000);
|
||||||
@ -22,6 +24,6 @@ public class ParkingTest {
|
|||||||
}catch(IllegalStateException e) {
|
}catch(IllegalStateException e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
P1.toString();
|
P1.toString();*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package parking;
|
package TD8.parking;
|
||||||
|
|
||||||
public class Voiture {
|
public class Voiture {
|
||||||
private int nbPorte;
|
private int nbPorte;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD8.pokemon;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.lang.Math;
|
import java.lang.Math;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD8.pokemon;
|
||||||
|
|
||||||
public abstract class Pokemon {
|
public abstract class Pokemon {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD8.pokemon;
|
||||||
|
|
||||||
public class PokemonEAU extends Pokemon{
|
public class PokemonEAU extends Pokemon{
|
||||||
private int nb_nageoires;
|
private int nb_nageoires;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD8.pokemon;
|
||||||
|
|
||||||
public class PokemonELECTRIK extends Pokemon {
|
public class PokemonELECTRIK extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD8.pokemon;
|
||||||
|
|
||||||
public class PokemonFEU extends Pokemon {
|
public class PokemonFEU extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD8.pokemon;
|
||||||
|
|
||||||
public class PokemonPLANTE extends Pokemon{
|
public class PokemonPLANTE extends Pokemon{
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD8.pokemon;
|
||||||
|
|
||||||
public class TestPokemon {
|
public class TestPokemon {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD8.pokemon;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package services;
|
package TD8.service;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package comparable;
|
package TD9.comparable;
|
||||||
|
|
||||||
public class ComparetoDepNom /*implements comparator<Personne>*/ {
|
public class ComparetoDepNom /*implements comparator<Personne>*/ {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package comparable;
|
package TD9.comparable;
|
||||||
|
|
||||||
public class Enseignant extends Personne{
|
public class Enseignant extends Personne{
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package comparable;
|
package TD9.comparable;
|
||||||
|
|
||||||
public class Etudiant extends Personne{
|
public class Etudiant extends Personne{
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package comparable;
|
package TD9.comparable;
|
||||||
|
|
||||||
public abstract class Personne implements Comparable<Personne>{
|
public abstract class Personne implements Comparable<Personne>{
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package comparable;
|
package TD9.comparable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD9.pokemon;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.lang.Math;
|
import java.lang.Math;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD9.pokemon;
|
||||||
|
|
||||||
public abstract class Pokemon implements Comparable<Pokemon> {
|
public abstract class Pokemon implements Comparable<Pokemon> {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD9.pokemon;
|
||||||
|
|
||||||
public class PokemonEAU extends Pokemon{
|
public class PokemonEAU extends Pokemon{
|
||||||
private int nb_nageoires;
|
private int nb_nageoires;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pokemon;
|
package TD9.pokemon;
|
||||||
|
|
||||||
public class PokemonELECTRIK extends Pokemon {
|
public class PokemonELECTRIK extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user