Refonte du repo
This commit is contained in:
parent
4962efbd17
commit
45f4d2dffe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
32
TD10/.vscode/launch.json
vendored
32
TD10/.vscode/launch.json
vendored
@ -1,32 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - LectureFichierAffichage",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "input.LectureFichierAffichage",
|
|
||||||
"projectName": "TD10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - Partie",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "pokemon.Partie",
|
|
||||||
"projectName": "TD10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - LectureFichierEcritureESP",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "input.LectureFichierEcritureESP",
|
|
||||||
"projectName": "TD10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - LectureFichier",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "input.LectureFichier",
|
|
||||||
"projectName": "TD10"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
package tripletEntier;
|
|
||||||
|
|
||||||
public class TripletEntier
|
|
||||||
{
|
|
||||||
private int un;
|
|
||||||
private int deux;
|
|
||||||
private int trois;
|
|
||||||
|
|
||||||
public TripletEntier()
|
|
||||||
{
|
|
||||||
un = 0;
|
|
||||||
deux = 0;
|
|
||||||
trois = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TripletEntier(int a, int b, int c)
|
|
||||||
{
|
|
||||||
un = a;
|
|
||||||
deux = b;
|
|
||||||
trois = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
//getter
|
|
||||||
public int getA() {
|
|
||||||
return un;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getB() {
|
|
||||||
return deux;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getC() {
|
|
||||||
return trois;
|
|
||||||
}
|
|
||||||
|
|
||||||
//setter
|
|
||||||
public void setA(int a) {
|
|
||||||
this.un = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setB(int b) {
|
|
||||||
this.deux = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setC(int c) {
|
|
||||||
this.trois = c;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
¸,ø¤º°`°º¤ø,¸¸,ø¤º°°º¤ø,¸¸,ø¤º°`°º¤ø,¸
|
|
||||||
Exercices demandés
|
|
||||||
¸,ø¤º°`°º¤ø,¸¸,ø¤º°°º¤ø,¸¸,ø¤º°`°º¤ø,¸
|
|
||||||
*/
|
|
||||||
|
|
||||||
public int somme()
|
|
||||||
{
|
|
||||||
int ret=this.un+this.deux+this.trois;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String concatenation()
|
|
||||||
{
|
|
||||||
return ""+this.un+this.deux+this.trois;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public double moyenne()
|
|
||||||
{
|
|
||||||
return ((double) somme() / 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "[a=" + un + ", b=" + deux + ", c=" + trois + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object o)
|
|
||||||
{
|
|
||||||
TripletEntier t = (TripletEntier) o;
|
|
||||||
return (this.un == t.un) && (this.deux == t.deux) && (this.trois == t.trois);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package fleuriste;
|
|
||||||
/*-------------------------------------------------
|
|
||||||
Tableau Fleurs
|
|
||||||
0 = roses 1 = tulipes 2 = oeillets
|
|
||||||
--------------------------------------------------*/
|
|
||||||
|
|
||||||
public class Bouquet {
|
|
||||||
|
|
||||||
private LotFleur lotFleurs[];
|
|
||||||
|
|
||||||
public LotFleur getLotFleur(int i) {
|
|
||||||
return lotFleurs[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLotFleur(LotFleur lotFleur, int i) {
|
|
||||||
this.lotFleurs[i] = lotFleur;
|
|
||||||
}
|
|
||||||
|
|
||||||
//instructions
|
|
||||||
public Bouquet(LotFleur l1, LotFleur l2, LotFleur l3){
|
|
||||||
lotFleurs[0] = l1;
|
|
||||||
lotFleurs[1] = l2;
|
|
||||||
lotFleurs[2] = l3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double prix() {
|
|
||||||
double resultat = 0.;
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
resultat = lotFleurs[i].getFleur().getPrix() * lotFleurs[i].getQuantite() + resultat;
|
|
||||||
}
|
|
||||||
return resultat;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package fleuriste;
|
|
||||||
|
|
||||||
public class Fleur {
|
|
||||||
|
|
||||||
private String nom;
|
|
||||||
private double prix;
|
|
||||||
|
|
||||||
//getters
|
|
||||||
|
|
||||||
public String getNom() {
|
|
||||||
return nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNom(String nom) {
|
|
||||||
this.nom = nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
//setters
|
|
||||||
|
|
||||||
public double getPrix() {
|
|
||||||
return prix;
|
|
||||||
}
|
|
||||||
public void setPrix(double prix) {
|
|
||||||
this.prix = prix;
|
|
||||||
}
|
|
||||||
//instructions
|
|
||||||
|
|
||||||
public Fleur(String nomFleur, double prixFleur) {
|
|
||||||
this.nom = nomFleur;
|
|
||||||
this.prix = prixFleur;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
package fleuriste;
|
|
||||||
/*-------------------------------------------------
|
|
||||||
Tableau Fleurs
|
|
||||||
0 = roses 1 = tulipes 2 = oeillets
|
|
||||||
--------------------------------------------------*/
|
|
||||||
|
|
||||||
public class Stock {
|
|
||||||
|
|
||||||
private int[] quantite;
|
|
||||||
|
|
||||||
//getters
|
|
||||||
|
|
||||||
public int[] getQuantite() {
|
|
||||||
return quantite;
|
|
||||||
}
|
|
||||||
|
|
||||||
//setters
|
|
||||||
|
|
||||||
public void setQuantite(int[] quantite) {
|
|
||||||
this.quantite = quantite;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Instructions
|
|
||||||
|
|
||||||
public Stock(Fleur f1, Fleur f2, Fleur f3) {
|
|
||||||
quantite[0] = 0;
|
|
||||||
quantite[1] = 0;
|
|
||||||
quantite[2] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ajouteFleur(int i, int quantiteFleur) {
|
|
||||||
if(i < 0 || i > 2)
|
|
||||||
{
|
|
||||||
System.err.println("Impossible, il n'y a pas de fleur de ce type !");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.quantite[i] = quantiteFleur;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean bouquetFaisable(Bouquet b1) {
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
if(quantite[i] > b1.getLotFleur(i).getQuantite())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package fleuriste;
|
|
||||||
|
|
||||||
public class TestBouquet {
|
|
||||||
public static void main( String[] args) {
|
|
||||||
// nom str nom = nom objet (ex :Tartampion)
|
|
||||||
Fleur rose = new Fleur("rose",2.6);
|
|
||||||
Fleur tulipe = new Fleur("tulipe",0.4);
|
|
||||||
Fleur oeillet = new Fleur("oeillet",1.8);
|
|
||||||
|
|
||||||
LotFleur lotroses = new LotFleur(rose,5);
|
|
||||||
LotFleur lottulipes = new LotFleur(tulipe,7);
|
|
||||||
LotFleur lotoeillets = new LotFleur(oeillet,3);
|
|
||||||
|
|
||||||
Bouquet b = new Bouquet(lotroses, lottulipes, lotoeillets);
|
|
||||||
double prixb = b.prix(); //calcule le prix d'un bouquet
|
|
||||||
System.out.println(b+" : "+prixb+" euros");
|
|
||||||
|
|
||||||
Stock magasin = new Stock(rose,tulipe,oeillet);
|
|
||||||
System.out.println(magasin);
|
|
||||||
magasin.ajouteFleur(0, 100);
|
|
||||||
magasin.ajouteFleur(1, 150);
|
|
||||||
magasin.ajouteFleur(2, 200);
|
|
||||||
System.out.println(magasin);
|
|
||||||
// Est-ce que le stock permet de produire le bouquet b ?
|
|
||||||
boolean orderBouquet = magasin.bouquetFaisable(b);
|
|
||||||
System.out.println(orderBouquet);
|
|
||||||
}
|
|
||||||
}
|
|
18
TD6/.vscode/launch.json
vendored
18
TD6/.vscode/launch.json
vendored
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - TestPokemon",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "pkmA.TestPokemon",
|
|
||||||
"projectName": "TD6"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - GestionVehicule",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "vehicule.GestionVehicule",
|
|
||||||
"projectName": "TD6"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
Binary file not shown.
18
TD8/.vscode/launch.json
vendored
18
TD8/.vscode/launch.json
vendored
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - TestPokemon",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "pokemon.TestPokemon",
|
|
||||||
"projectName": "TD8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - TestExercices",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "services.TestExercices",
|
|
||||||
"projectName": "TD8"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
18
TD9/.vscode/launch.json
vendored
18
TD9/.vscode/launch.json
vendored
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - TestPokemon",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "pokemon.TestPokemon",
|
|
||||||
"projectName": "TD9"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "java",
|
|
||||||
"name": "CodeLens (Launch) - main",
|
|
||||||
"request": "launch",
|
|
||||||
"mainClass": "comparable.main",
|
|
||||||
"projectName": "TD9"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package pokemon;
|
|
||||||
|
|
||||||
enum Type {
|
|
||||||
|
|
||||||
EAU("EAU"),
|
|
||||||
ELECTRIK("ELECTRIK"),
|
|
||||||
FEU("FEU"),
|
|
||||||
PLANTE("PLANTE");
|
|
||||||
|
|
||||||
Type(String s) {
|
|
||||||
description = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,102 +0,0 @@
|
|||||||
package journey;
|
|
||||||
|
|
||||||
public class Point
|
|
||||||
{
|
|
||||||
//attributs
|
|
||||||
private double x;
|
|
||||||
private double y;
|
|
||||||
public List<Trajet> trajet = new ArrayList<Trajet> ();
|
|
||||||
|
|
||||||
|
|
||||||
//constructeurs
|
|
||||||
public Point()
|
|
||||||
{
|
|
||||||
x = 0;
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point(double x, double y)
|
|
||||||
{
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
//methode d'instance
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "(X = " + this.x + " - Y = " + this.y + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDistance(Point p)
|
|
||||||
{
|
|
||||||
double result;
|
|
||||||
result = Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//accesseur en lecture
|
|
||||||
public double getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point projX()
|
|
||||||
{
|
|
||||||
return new Point(this.x, 0.);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point projY()
|
|
||||||
{
|
|
||||||
return new Point(0., this.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals (Object obj)
|
|
||||||
{
|
|
||||||
Point p = (Point)obj;
|
|
||||||
if (this.x == p.x && this.y == p.y)
|
|
||||||
return true;
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point clone()
|
|
||||||
{
|
|
||||||
return new Point(this.x, this.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getLocation()
|
|
||||||
{
|
|
||||||
System.out.println("x = " + this.x + " , y = " + this.y + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocation(Point p)
|
|
||||||
{
|
|
||||||
p.x = this.x;
|
|
||||||
p.y = this.y;
|
|
||||||
}
|
|
||||||
public void setLocation(double x, double y)
|
|
||||||
{
|
|
||||||
x = this.x;
|
|
||||||
y = this.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void translate(int dx, int dy)
|
|
||||||
{
|
|
||||||
this.x = this.x+dx;
|
|
||||||
this.y = this.y+dy;
|
|
||||||
}
|
|
||||||
|
|
||||||
//getters and setters
|
|
||||||
public void setX(double x) {
|
|
||||||
this.x = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setY(double y) {
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
package journey;
|
|
||||||
|
|
||||||
public class Trajet {
|
|
||||||
private String nom;
|
|
||||||
private Integer nombrePoints;
|
|
||||||
private int tabDistance[];
|
|
||||||
|
|
||||||
public int getTabDistance[]() {
|
|
||||||
|
|
||||||
return this.tabDistance[];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTabDistance[](final int value) {
|
|
||||||
this.tabDistance[] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNom() {
|
|
||||||
return this.nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNom(final String value) {
|
|
||||||
this.nom = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getNombrePoints() {
|
|
||||||
return this.nombrePoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sommeDistance() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
0
TD1/TD1.pdf → TDs/TD1.pdf
Executable file → Normal file
0
TD1/TD1.pdf → TDs/TD1.pdf
Executable file → Normal file
0
TD10/TD10.pdf → TDs/TD10.pdf
Executable file → Normal file
0
TD10/TD10.pdf → TDs/TD10.pdf
Executable file → Normal file
0
TD2/TD2.pdf → TDs/TD2.pdf
Executable file → Normal file
0
TD2/TD2.pdf → TDs/TD2.pdf
Executable file → Normal file
0
TD3/TD3.pdf → TDs/TD3.pdf
Executable file → Normal file
0
TD3/TD3.pdf → TDs/TD3.pdf
Executable file → Normal file
0
TD4/TD4.pdf → TDs/TD4.pdf
Executable file → Normal file
0
TD4/TD4.pdf → TDs/TD4.pdf
Executable file → Normal file
0
TD5/TD5.pdf → TDs/TD5.pdf
Executable file → Normal file
0
TD5/TD5.pdf → TDs/TD5.pdf
Executable file → Normal file
0
TD6/TD6.pdf → TDs/TD6.pdf
Executable file → Normal file
0
TD6/TD6.pdf → TDs/TD6.pdf
Executable file → Normal file
0
TD7/TD7.pdf → TDs/TD7.pdf
Executable file → Normal file
0
TD7/TD7.pdf → TDs/TD7.pdf
Executable file → Normal file
0
TD8/TD8.pdf → TDs/TD8.pdf
Executable file → Normal file
0
TD8/TD8.pdf → TDs/TD8.pdf
Executable file → Normal file
0
TD9/TD9.pdf → TDs/TD9.pdf
Executable file → Normal file
0
TD9/TD9.pdf → TDs/TD9.pdf
Executable file → Normal file
12
TD1/src/HelloWorld.java → src/TD1/HelloWorld.java
Executable file → Normal file
12
TD1/src/HelloWorld.java → src/TD1/HelloWorld.java
Executable file → Normal file
@ -1,7 +1,7 @@
|
|||||||
public class HelloWorld
|
public class HelloWorld
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
System.out.println("\nHelloWord ! :)");
|
System.out.println("\nHelloWord ! :)");
|
||||||
}
|
}
|
||||||
}
|
}
|
200
TD1/src/point/Point.java → src/TD1/point/Point.java
Executable file → Normal file
200
TD1/src/point/Point.java → src/TD1/point/Point.java
Executable file → Normal file
@ -1,100 +1,100 @@
|
|||||||
package point;
|
package point;
|
||||||
|
|
||||||
public class Point
|
public class Point
|
||||||
{
|
{
|
||||||
//attributs
|
//attributs
|
||||||
public double x;
|
public double x;
|
||||||
public double y;
|
public double y;
|
||||||
|
|
||||||
|
|
||||||
//constructeurs
|
//constructeurs
|
||||||
public Point()
|
public Point()
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point(double x, double y)
|
public Point(double x, double y)
|
||||||
{
|
{
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
//methode d'instance
|
//methode d'instance
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "(X = " + this.x + " - Y = " + this.y + ")";
|
return "(X = " + this.x + " - Y = " + this.y + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDistance(Point p)
|
public double getDistance(Point p)
|
||||||
{
|
{
|
||||||
double result;
|
double result;
|
||||||
result = Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
|
result = Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//accesseur en lecture
|
//accesseur en lecture
|
||||||
public double getX() {
|
public double getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getY() {
|
public double getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point projX()
|
public Point projX()
|
||||||
{
|
{
|
||||||
return new Point(this.x, 0.);
|
return new Point(this.x, 0.);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point projY()
|
public Point projY()
|
||||||
{
|
{
|
||||||
return new Point(0., this.y);
|
return new Point(0., this.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals (Object obj)
|
public boolean equals (Object obj)
|
||||||
{
|
{
|
||||||
Point p = (Point)obj;
|
Point p = (Point)obj;
|
||||||
if (this.x == p.x && this.y == p.y)
|
if (this.x == p.x && this.y == p.y)
|
||||||
return true;
|
return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point clone()
|
public Point clone()
|
||||||
{
|
{
|
||||||
return new Point(this.x, this.y);
|
return new Point(this.x, this.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getLocation()
|
public void getLocation()
|
||||||
{
|
{
|
||||||
System.out.println("x = " + this.x + " , y = " + this.y + ".");
|
System.out.println("x = " + this.x + " , y = " + this.y + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(Point p)
|
public void setLocation(Point p)
|
||||||
{
|
{
|
||||||
p.x = this.x;
|
p.x = this.x;
|
||||||
p.y = this.y;
|
p.y = this.y;
|
||||||
}
|
}
|
||||||
public void setLocation(double x, double y)
|
public void setLocation(double x, double y)
|
||||||
{
|
{
|
||||||
x = this.x;
|
x = this.x;
|
||||||
y = this.y;
|
y = this.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void translate(int dx, int dy)
|
public void translate(int dx, int dy)
|
||||||
{
|
{
|
||||||
this.x = this.x+dx;
|
this.x = this.x+dx;
|
||||||
this.y = this.y+dy;
|
this.y = this.y+dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
//getters and setters
|
//getters and setters
|
||||||
public void setX(double x) {
|
public void setX(double x) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setY(double y) {
|
public void setY(double y) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
28
TD1/src/point/PointTest.java → src/TD1/point/PointTest.java
Executable file → Normal file
28
TD1/src/point/PointTest.java → src/TD1/point/PointTest.java
Executable file → Normal file
@ -1,14 +1,14 @@
|
|||||||
package point;
|
package point;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
class PointTest {
|
class PointTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test() {
|
void test() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
152
TD1/src/point/TestPoint.java → src/TD1/point/TestPoint.java
Executable file → Normal file
152
TD1/src/point/TestPoint.java → src/TD1/point/TestPoint.java
Executable file → Normal file
@ -1,76 +1,76 @@
|
|||||||
package point;
|
package point;
|
||||||
|
|
||||||
public class TestPoint {
|
public class TestPoint {
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
Point O = new Point();
|
Point O = new Point();
|
||||||
Point I = new Point(1.0, 0.0);
|
Point I = new Point(1.0, 0.0);
|
||||||
Point J = new Point(0.0, 1.0);
|
Point J = new Point(0.0, 1.0);
|
||||||
Point A = new Point(1.0, 3.5);
|
Point A = new Point(1.0, 3.5);
|
||||||
Point B = new Point(8.0, 20.0);
|
Point B = new Point(8.0, 20.0);
|
||||||
Point C = new Point(-2.0, 3.0);
|
Point C = new Point(-2.0, 3.0);
|
||||||
Point D = new Point(1.0, 1.0);
|
Point D = new Point(1.0, 1.0);
|
||||||
|
|
||||||
|
|
||||||
System.out.println(" O = " + O.toString());
|
System.out.println(" O = " + O.toString());
|
||||||
System.out.println(" I = " + I.toString());
|
System.out.println(" I = " + I.toString());
|
||||||
System.out.println(" J = " + J.toString());
|
System.out.println(" J = " + J.toString());
|
||||||
System.out.println(" A = " + A.toString());
|
System.out.println(" A = " + A.toString());
|
||||||
System.out.println(" B = " + B.toString());
|
System.out.println(" B = " + B.toString());
|
||||||
System.out.println(" C = " + C.toString());
|
System.out.println(" C = " + C.toString());
|
||||||
System.out.println(" D = " + D.toString());
|
System.out.println(" D = " + D.toString());
|
||||||
|
|
||||||
System.out.println("La distance O - I est de " + O.getDistance(I));
|
System.out.println("La distance O - I est de " + O.getDistance(I));
|
||||||
System.out.println("La distance O - J est de " + O.getDistance(J));
|
System.out.println("La distance O - J est de " + O.getDistance(J));
|
||||||
System.out.println("La distance J - I est de " + J.getDistance(I));
|
System.out.println("La distance J - I est de " + J.getDistance(I));
|
||||||
System.out.println("La distance A - B est de " + A.getDistance(B));
|
System.out.println("La distance A - B est de " + A.getDistance(B));
|
||||||
System.out.println("La distance B - A est de " + B.getDistance(A));
|
System.out.println("La distance B - A est de " + B.getDistance(A));
|
||||||
System.out.println("La distance A - C est de " + A.getDistance(C));
|
System.out.println("La distance A - C est de " + A.getDistance(C));
|
||||||
System.out.println("La distance C - A est de " + C.getDistance(A));
|
System.out.println("La distance C - A est de " + C.getDistance(A));
|
||||||
System.out.println("La distance O - D est de " + O.getDistance(D));
|
System.out.println("La distance O - D est de " + O.getDistance(D));
|
||||||
|
|
||||||
System.out.println("Le getX de A est " + A.getX());
|
System.out.println("Le getX de A est " + A.getX());
|
||||||
System.out.println("Le getY de A est " + A.getY());
|
System.out.println("Le getY de A est " + A.getY());
|
||||||
|
|
||||||
System.out.println("Le ProjX de A est " + A.projX());
|
System.out.println("Le ProjX de A est " + A.projX());
|
||||||
System.out.println("Le ProjY de A est " + A.projY());
|
System.out.println("Le ProjY de A est " + A.projY());
|
||||||
System.out.println("Le ProjX de B est " + B.projX());
|
System.out.println("Le ProjX de B est " + B.projX());
|
||||||
System.out.println("Le ProjY de B est " + B.projY());
|
System.out.println("Le ProjY de B est " + B.projY());
|
||||||
System.out.println("Le ProjX de O est " + O.projX());
|
System.out.println("Le ProjX de O est " + O.projX());
|
||||||
System.out.println("Le ProjY de O est " + O.projY());
|
System.out.println("Le ProjY de O est " + O.projY());
|
||||||
System.out.println("Le ProjX de I est " + I.projX());
|
System.out.println("Le ProjX de I est " + I.projX());
|
||||||
System.out.println("Le ProjY de I est " + I.projY());
|
System.out.println("Le ProjY de I est " + I.projY());
|
||||||
System.out.println("Le ProjX de J est " + J.projX());
|
System.out.println("Le ProjX de J est " + J.projX());
|
||||||
System.out.println("Le ProjY de J est " + J.projY());
|
System.out.println("Le ProjY de J est " + J.projY());
|
||||||
|
|
||||||
System.out.println(A.equals(A));
|
System.out.println(A.equals(A));
|
||||||
System.out.println(O.equals(O));
|
System.out.println(O.equals(O));
|
||||||
System.out.println(I.equals(J));
|
System.out.println(I.equals(J));
|
||||||
System.out.println(J.equals(I));
|
System.out.println(J.equals(I));
|
||||||
System.out.println(B.equals(B));
|
System.out.println(B.equals(B));
|
||||||
System.out.println(C.equals(C));
|
System.out.println(C.equals(C));
|
||||||
|
|
||||||
|
|
||||||
/*A.setLocation(5., 2.);
|
/*A.setLocation(5., 2.);
|
||||||
B.setLocation(3., -2.);
|
B.setLocation(3., -2.);
|
||||||
C.setLocation(6., 5.);
|
C.setLocation(6., 5.);
|
||||||
O.setLocation(-5., 8.);*/
|
O.setLocation(-5., 8.);*/
|
||||||
|
|
||||||
A.translate(5, 2);
|
A.translate(5, 2);
|
||||||
B.translate(3, -2);
|
B.translate(3, -2);
|
||||||
C.translate(6, 5);
|
C.translate(6, 5);
|
||||||
O.translate(-5, 8);
|
O.translate(-5, 8);
|
||||||
|
|
||||||
|
|
||||||
System.out.println(A.toString());
|
System.out.println(A.toString());
|
||||||
System.out.println(B.toString());
|
System.out.println(B.toString());
|
||||||
System.out.println(C.toString());
|
System.out.println(C.toString());
|
||||||
System.out.println(O.toString());
|
System.out.println(O.toString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
68
TD10/src/input/LectureFichierAffichage.java → src/TD10/input/LectureFichierAffichage.java
Executable file → Normal file
68
TD10/src/input/LectureFichierAffichage.java → src/TD10/input/LectureFichierAffichage.java
Executable file → Normal file
@ -1,34 +1,34 @@
|
|||||||
package input;
|
package input;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class LectureFichierAffichage {
|
public class LectureFichierAffichage {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
FileReader cp2009 = new FileReader("-France_Codepostal_2009.txt");
|
FileReader cp2009 = new FileReader("-France_Codepostal_2009.txt");
|
||||||
BufferedReader readerCP2009 = new BufferedReader(cp2009);
|
BufferedReader readerCP2009 = new BufferedReader(cp2009);
|
||||||
|
|
||||||
while (readerCP2009.ready()) {
|
while (readerCP2009.ready()) {
|
||||||
String displayLine = readerCP2009.readLine();
|
String displayLine = readerCP2009.readLine();
|
||||||
System.out.println(displayLine);
|
System.out.println(displayLine);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readerCP2009.close();
|
readerCP2009.close();
|
||||||
cp2009.close();
|
cp2009.close();
|
||||||
|
|
||||||
} catch(FileNotFoundException e) {
|
} catch(FileNotFoundException e) {
|
||||||
|
|
||||||
System.err.println("Fichier non trouve");
|
System.err.println("Fichier non trouve");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("Fichier indisponible");
|
System.err.println("Fichier indisponible");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
98
TD10/src/input/LectureFichierEcriture.java → src/TD10/input/LectureFichierEcriture.java
Executable file → Normal file
98
TD10/src/input/LectureFichierEcriture.java → src/TD10/input/LectureFichierEcriture.java
Executable file → Normal file
@ -1,49 +1,49 @@
|
|||||||
package input;
|
package input;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class LectureFichierEcriture {
|
public class LectureFichierEcriture {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
FileReader cp2009 = new FileReader("-France_Codepostal_2009.txt");
|
FileReader cp2009 = new FileReader("-France_Codepostal_2009.txt");
|
||||||
FileWriter FC2009 = new FileWriter("France_Communes_2009.txt");
|
FileWriter FC2009 = new FileWriter("France_Communes_2009.txt");
|
||||||
FileWriter C2009 = new FileWriter("France_Code_Postal_2009.txt");
|
FileWriter C2009 = new FileWriter("France_Code_Postal_2009.txt");
|
||||||
|
|
||||||
BufferedReader readerCP2009 = new BufferedReader(cp2009);
|
BufferedReader readerCP2009 = new BufferedReader(cp2009);
|
||||||
BufferedWriter bufferCP = new BufferedWriter(C2009);
|
BufferedWriter bufferCP = new BufferedWriter(C2009);
|
||||||
BufferedWriter bufferCommune = new BufferedWriter(FC2009);
|
BufferedWriter bufferCommune = new BufferedWriter(FC2009);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (readerCP2009.ready()) {
|
while (readerCP2009.ready()) {
|
||||||
String displayLine = readerCP2009.readLine();
|
String displayLine = readerCP2009.readLine();
|
||||||
String[] tabs = displayLine.split("\t");
|
String[] tabs = displayLine.split("\t");
|
||||||
|
|
||||||
bufferCP.write(tabs[0]);
|
bufferCP.write(tabs[0]);
|
||||||
bufferCP.newLine();
|
bufferCP.newLine();
|
||||||
bufferCommune.write(tabs[1]);
|
bufferCommune.write(tabs[1]);
|
||||||
bufferCommune.newLine();
|
bufferCommune.newLine();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readerCP2009.close();
|
readerCP2009.close();
|
||||||
cp2009.close();
|
cp2009.close();
|
||||||
FC2009.close();
|
FC2009.close();
|
||||||
C2009.close();
|
C2009.close();
|
||||||
|
|
||||||
} catch(FileNotFoundException e) {
|
} catch(FileNotFoundException e) {
|
||||||
|
|
||||||
System.err.println("Fichier non trouve");
|
System.err.println("Fichier non trouve");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("Fichier indisponible");
|
System.err.println("Fichier indisponible");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
110
TD10/src/input/LectureFichierEcritureESP.java → src/TD10/input/LectureFichierEcritureESP.java
Executable file → Normal file
110
TD10/src/input/LectureFichierEcritureESP.java → src/TD10/input/LectureFichierEcritureESP.java
Executable file → Normal file
@ -1,55 +1,55 @@
|
|||||||
package input;
|
package input;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class LectureFichierEcritureESP {
|
public class LectureFichierEcritureESP {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
FileReader cp2009 = new FileReader("-France_Codepostal_2009_esp.txt");
|
FileReader cp2009 = new FileReader("-France_Codepostal_2009_esp.txt");
|
||||||
FileWriter FC2009 = new FileWriter("France_Code_Postal_2009ESP.txt");
|
FileWriter FC2009 = new FileWriter("France_Code_Postal_2009ESP.txt");
|
||||||
FileWriter C2009 = new FileWriter("France_Communes_2009ESP.txt");
|
FileWriter C2009 = new FileWriter("France_Communes_2009ESP.txt");
|
||||||
|
|
||||||
BufferedReader readerCP2009 = new BufferedReader(cp2009);
|
BufferedReader readerCP2009 = new BufferedReader(cp2009);
|
||||||
BufferedWriter bufferCP = new BufferedWriter(C2009);
|
BufferedWriter bufferCP = new BufferedWriter(C2009);
|
||||||
BufferedWriter bufferCommune = new BufferedWriter(FC2009);
|
BufferedWriter bufferCommune = new BufferedWriter(FC2009);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (readerCP2009.ready()) {
|
while (readerCP2009.ready()) {
|
||||||
String displayLine = readerCP2009.readLine();
|
String displayLine = readerCP2009.readLine();
|
||||||
String[] tabs = displayLine.split(" ");
|
String[] tabs = displayLine.split(" ");
|
||||||
|
|
||||||
tabs[(tabs.length) - 1] = "\t" + tabs[(tabs.length) - 1];
|
tabs[(tabs.length) - 1] = "\t" + tabs[(tabs.length) - 1];
|
||||||
|
|
||||||
for (int i = 0; i < (tabs.length - 1); i++) {
|
for (int i = 0; i < (tabs.length - 1); i++) {
|
||||||
bufferCP.write(tabs[i] + " ");
|
bufferCP.write(tabs[i] + " ");
|
||||||
}
|
}
|
||||||
bufferCP.newLine();
|
bufferCP.newLine();
|
||||||
|
|
||||||
bufferCommune.write(tabs.length);
|
bufferCommune.write(tabs.length);
|
||||||
bufferCommune.newLine();
|
bufferCommune.newLine();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readerCP2009.close();
|
readerCP2009.close();
|
||||||
cp2009.close();
|
cp2009.close();
|
||||||
FC2009.close();
|
FC2009.close();
|
||||||
C2009.close();
|
C2009.close();
|
||||||
|
|
||||||
|
|
||||||
} catch(FileNotFoundException e) {
|
} catch(FileNotFoundException e) {
|
||||||
|
|
||||||
System.err.println("Fichier non trouve");
|
System.err.println("Fichier non trouve");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("Fichier indisponible");
|
System.err.println("Fichier indisponible");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
242
TD10/src/pokemon/Joueur.java → src/TD10/pokemon/Joueur.java
Executable file → Normal file
242
TD10/src/pokemon/Joueur.java → src/TD10/pokemon/Joueur.java
Executable file → Normal file
@ -1,121 +1,121 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.lang.Math;
|
import java.lang.Math;
|
||||||
|
|
||||||
public class Joueur implements Comparable<Joueur> {
|
public class Joueur implements Comparable<Joueur> {
|
||||||
|
|
||||||
private String nom;
|
private String nom;
|
||||||
private int niveau; //Nombre pokemon captures
|
private int niveau; //Nombre pokemon captures
|
||||||
private int nbPoints; //Nombre pokemon actuel
|
private int nbPoints; //Nombre pokemon actuel
|
||||||
private ArrayList<Pokemon> pokemon;
|
private ArrayList<Pokemon> pokemon;
|
||||||
|
|
||||||
public Joueur() {
|
public Joueur() {
|
||||||
|
|
||||||
this.nom = null;
|
this.nom = null;
|
||||||
this.niveau = 1;
|
this.niveau = 1;
|
||||||
this.nbPoints = 0;
|
this.nbPoints = 0;
|
||||||
this.pokemon = new ArrayList<Pokemon>();
|
this.pokemon = new ArrayList<Pokemon>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Joueur(String s) {
|
public Joueur(String s) {
|
||||||
this.nom = s;
|
this.nom = s;
|
||||||
this.niveau = 1;
|
this.niveau = 1;
|
||||||
this.nbPoints = 0;
|
this.nbPoints = 0;
|
||||||
this.pokemon = new ArrayList<Pokemon>();
|
this.pokemon = new ArrayList<Pokemon>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "================================================================================\n" + "Le joueur " + this.nom + " a " + this.niveau + " pokemons!\nLes pokemons qu'il possede sont : " + this.pokemon.toString() + "\n================================================================================";
|
return "================================================================================\n" + "Le joueur " + this.nom + " a " + this.niveau + " pokemons!\nLes pokemons qu'il possede sont : " + this.pokemon.toString() + "\n================================================================================";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(Joueur j)
|
public int compareTo(Joueur j)
|
||||||
{
|
{
|
||||||
return this.getNom().compareTo(j.getNom());
|
return this.getNom().compareTo(j.getNom());
|
||||||
}
|
}
|
||||||
|
|
||||||
public double vitesseMoyenne() {
|
public double vitesseMoyenne() {
|
||||||
|
|
||||||
if(pokemon.isEmpty())
|
if(pokemon.isEmpty())
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double moyenne = 0.;
|
double moyenne = 0.;
|
||||||
|
|
||||||
for (Pokemon p : pokemon) {
|
for (Pokemon p : pokemon) {
|
||||||
moyenne += p.calculerVitesse();
|
moyenne += p.calculerVitesse();
|
||||||
}
|
}
|
||||||
|
|
||||||
return moyenne/pokemon.size();
|
return moyenne/pokemon.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double vitesseMoyenne(String s) {
|
public double vitesseMoyenne(String s) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if(pokemon.isEmpty())
|
if(pokemon.isEmpty())
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double moyenne = 0.;
|
double moyenne = 0.;
|
||||||
|
|
||||||
for (Pokemon p : pokemon) {
|
for (Pokemon p : pokemon) {
|
||||||
|
|
||||||
if(p.getType().getDescription().equals(s))
|
if(p.getType().getDescription().equals(s))
|
||||||
{
|
{
|
||||||
moyenne += p.calculerVitesse();
|
moyenne += p.calculerVitesse();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return moyenne/count;
|
return moyenne/count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attrapePokemon(Pokemon p){
|
public void attrapePokemon(Pokemon p){
|
||||||
this.niveau++;
|
this.niveau++;
|
||||||
this.nbPoints++;
|
this.nbPoints++;
|
||||||
this.pokemon.add(p);
|
this.pokemon.add(p);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void relachePokemon(Pokemon p) {
|
public void relachePokemon(Pokemon p) {
|
||||||
this.nbPoints--;
|
this.nbPoints--;
|
||||||
this.pokemon.remove(p);
|
this.pokemon.remove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attack(Object obj) {
|
public void attack(Object obj) {
|
||||||
Joueur j = (Joueur)obj;
|
Joueur j = (Joueur)obj;
|
||||||
int x = (int)Math.random()*this.getPokemon().size();
|
int x = (int)Math.random()*this.getPokemon().size();
|
||||||
int y = (int)Math.random()*j.getPokemon().size();
|
int y = (int)Math.random()*j.getPokemon().size();
|
||||||
this.pokemon.get(x).attack(this.pokemon.get(y));
|
this.pokemon.get(x).attack(this.pokemon.get(y));
|
||||||
j.pokemon.get(y).attack(this.pokemon.get(x));
|
j.pokemon.get(y).attack(this.pokemon.get(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNom() {
|
public String getNom() {
|
||||||
return nom;
|
return nom;
|
||||||
}
|
}
|
||||||
public void setNom(String nom) {
|
public void setNom(String nom) {
|
||||||
this.nom = nom;
|
this.nom = nom;
|
||||||
}
|
}
|
||||||
public int getNiveau() {
|
public int getNiveau() {
|
||||||
return niveau;
|
return niveau;
|
||||||
}
|
}
|
||||||
public void setNiveau(int niveau) {
|
public void setNiveau(int niveau) {
|
||||||
this.niveau = niveau;
|
this.niveau = niveau;
|
||||||
}
|
}
|
||||||
public int getNbPoints() {
|
public int getNbPoints() {
|
||||||
return nbPoints;
|
return nbPoints;
|
||||||
}
|
}
|
||||||
public void setNbPoints(int nbPoints) {
|
public void setNbPoints(int nbPoints) {
|
||||||
this.nbPoints = nbPoints;
|
this.nbPoints = nbPoints;
|
||||||
}
|
}
|
||||||
public ArrayList<Pokemon> getPokemon() {
|
public ArrayList<Pokemon> getPokemon() {
|
||||||
return pokemon;
|
return pokemon;
|
||||||
}
|
}
|
||||||
public void setPokemon(ArrayList<Pokemon> pokemon) {
|
public void setPokemon(ArrayList<Pokemon> pokemon) {
|
||||||
this.pokemon = pokemon;
|
this.pokemon = pokemon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
164
TD10/src/pokemon/Partie.java → src/TD10/pokemon/Partie.java
Executable file → Normal file
164
TD10/src/pokemon/Partie.java → src/TD10/pokemon/Partie.java
Executable file → Normal file
@ -1,83 +1,83 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
new PokemonFEU(String n, double t, double p, int pv, int pc, int g)
|
new PokemonFEU(String n, double t, double p, int pv, int pc, int g)
|
||||||
new PokemonEAU(String n, double t, double p, int pv, int pc, int g)
|
new PokemonEAU(String n, double t, double p, int pv, int pc, int g)
|
||||||
new PokemonELECTRIK(String n, double t, double p, int pv, int pc, int g, int a, double i)
|
new PokemonELECTRIK(String n, double t, double p, int pv, int pc, int g, int a, double i)
|
||||||
new PokemonPLANTE(String n, double t, double p, int pv, int pc)
|
new PokemonPLANTE(String n, double t, double p, int pv, int pc)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Partie {
|
public class Partie {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
ArrayList<Pokemon> listePKM = new ArrayList<Pokemon>();
|
ArrayList<Pokemon> listePKM = new ArrayList<Pokemon>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
FileReader lecturePkm = new FileReader("-ListePokemon.txt");
|
FileReader lecturePkm = new FileReader("-ListePokemon.txt");
|
||||||
BufferedReader bufferPkm = new BufferedReader(lecturePkm);
|
BufferedReader bufferPkm = new BufferedReader(lecturePkm);
|
||||||
|
|
||||||
while (bufferPkm.ready()) {
|
while (bufferPkm.ready()) {
|
||||||
String displayLine = bufferPkm.readLine();
|
String displayLine = bufferPkm.readLine();
|
||||||
String[] tabs = displayLine.split(" ");
|
String[] tabs = displayLine.split(" ");
|
||||||
|
|
||||||
String typePKM = tabs[1];
|
String typePKM = tabs[1];
|
||||||
|
|
||||||
// nom - type - taille - poids - pv - pc
|
// nom - type - taille - poids - pv - pc
|
||||||
|
|
||||||
switch (typePKM) {
|
switch (typePKM) {
|
||||||
case "Feu":
|
case "Feu":
|
||||||
PokemonFEU pF = new PokemonFEU(tabs[0], Double.parseDouble(tabs[2]), Double.parseDouble(tabs[3]),
|
PokemonFEU pF = new PokemonFEU(tabs[0], Double.parseDouble(tabs[2]), Double.parseDouble(tabs[3]),
|
||||||
Integer.parseInt(tabs[4]), Integer.parseInt(tabs[5]), Integer.parseInt(tabs[6]));
|
Integer.parseInt(tabs[4]), Integer.parseInt(tabs[5]), Integer.parseInt(tabs[6]));
|
||||||
listePKM.add(pF);
|
listePKM.add(pF);
|
||||||
// On créer ici un pokemon feu que l'on ajoute à notre ArrayList
|
// On créer ici un pokemon feu que l'on ajoute à notre ArrayList
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Eau":
|
case "Eau":
|
||||||
PokemonEAU pE = new PokemonEAU(tabs[0], Double.parseDouble(tabs[2]), Double.parseDouble(tabs[3]),
|
PokemonEAU pE = new PokemonEAU(tabs[0], Double.parseDouble(tabs[2]), Double.parseDouble(tabs[3]),
|
||||||
Integer.parseInt(tabs[4]), Integer.parseInt(tabs[5]), Integer.parseInt(tabs[6]));
|
Integer.parseInt(tabs[4]), Integer.parseInt(tabs[5]), Integer.parseInt(tabs[6]));
|
||||||
listePKM.add(pE);
|
listePKM.add(pE);
|
||||||
// On créer ici un pokemon feu que l'on ajoute à notre ArrayList
|
// On créer ici un pokemon feu que l'on ajoute à notre ArrayList
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Plante":
|
case "Plante":
|
||||||
PokemonPLANTE pP = new PokemonPLANTE(tabs[0], Double.parseDouble(tabs[2]),
|
PokemonPLANTE pP = new PokemonPLANTE(tabs[0], Double.parseDouble(tabs[2]),
|
||||||
Double.parseDouble(tabs[3]), Integer.parseInt(tabs[4]), Integer.parseInt(tabs[5]));
|
Double.parseDouble(tabs[3]), Integer.parseInt(tabs[4]), Integer.parseInt(tabs[5]));
|
||||||
listePKM.add(pP);
|
listePKM.add(pP);
|
||||||
// On créer ici un pokemon feu que l'on ajoute à notre ArrayList
|
// On créer ici un pokemon feu que l'on ajoute à notre ArrayList
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Electrik":
|
case "Electrik":
|
||||||
PokemonELECTRIK pEl = new PokemonELECTRIK(tabs[0], Double.parseDouble(tabs[2]),
|
PokemonELECTRIK pEl = new PokemonELECTRIK(tabs[0], Double.parseDouble(tabs[2]),
|
||||||
Double.parseDouble(tabs[3]), Integer.parseInt(tabs[4]), Integer.parseInt(tabs[5]),
|
Double.parseDouble(tabs[3]), Integer.parseInt(tabs[4]), Integer.parseInt(tabs[5]),
|
||||||
Integer.parseInt(tabs[6]), Integer.parseInt(tabs[7]), Double.parseDouble(tabs[8]));
|
Integer.parseInt(tabs[6]), Integer.parseInt(tabs[7]), Double.parseDouble(tabs[8]));
|
||||||
listePKM.add(pEl);
|
listePKM.add(pEl);
|
||||||
// On créer ici un pokemon feu que l'on ajoute à notre ArrayList
|
// On créer ici un pokemon feu que l'on ajoute à notre ArrayList
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
System.err.println("Erreur");
|
System.err.println("Erreur");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
System.out.println(listePKM.toString());
|
System.out.println(listePKM.toString());
|
||||||
|
|
||||||
bufferPkm.close();
|
bufferPkm.close();
|
||||||
lecturePkm.close();
|
lecturePkm.close();
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
|
|
||||||
System.err.println("Fichier non trouve");
|
System.err.println("Fichier non trouve");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("Fichier indisponible");
|
System.err.println("Fichier indisponible");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
212
TD9/src/pokemon/Pokemon.java → src/TD10/pokemon/Pokemon.java
Executable file → Normal file
212
TD9/src/pokemon/Pokemon.java → src/TD10/pokemon/Pokemon.java
Executable file → Normal file
@ -1,106 +1,106 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public abstract class Pokemon implements Comparable<Pokemon> {
|
public abstract class Pokemon implements Comparable<Pokemon> {
|
||||||
|
|
||||||
private String nom;
|
private String nom;
|
||||||
private double taille; // en m
|
private double taille; // en m
|
||||||
private double poids; // en kg
|
private double poids; // en kg
|
||||||
private int pv;
|
private int pv;
|
||||||
private int pc;
|
private int pc;
|
||||||
Type type;
|
Type type;
|
||||||
|
|
||||||
|
|
||||||
public Pokemon() {
|
public Pokemon() {
|
||||||
nom = null;
|
nom = null;
|
||||||
taille = 0.;
|
taille = 0.;
|
||||||
poids = 0.;
|
poids = 0.;
|
||||||
pv = 0;
|
pv = 0;
|
||||||
pc = 0;
|
pc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pokemon(String n, double t, double p, int pv, int pc) {
|
public Pokemon(String n, double t, double p, int pv, int pc) {
|
||||||
this.nom = n;
|
this.nom = n;
|
||||||
this.taille = t;
|
this.taille = t;
|
||||||
this.poids = p;
|
this.poids = p;
|
||||||
this.pv = pv;
|
this.pv = pv;
|
||||||
this.pc = pc;
|
this.pc = pc;
|
||||||
this.type = null;
|
this.type = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.getNom();
|
return this.getNom();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(Pokemon p)
|
public int compareTo(Pokemon p)
|
||||||
{
|
{
|
||||||
int r = this.getType().getDescription().compareTo(p.getType().getDescription());
|
int r = this.getType().getDescription().compareTo(p.getType().getDescription());
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
return this.getPv() - p.getPv();
|
return this.getPv() - p.getPv();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//getters
|
//getters
|
||||||
public String getNom() {
|
public String getNom() {
|
||||||
return nom;
|
return nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTaille() {
|
public double getTaille() {
|
||||||
return taille;
|
return taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPoids() {
|
public double getPoids() {
|
||||||
return poids;
|
return poids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPv() {
|
public int getPv() {
|
||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPc() {
|
public int getPc() {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
//setters
|
//setters
|
||||||
public void setNom(String nom) {
|
public void setNom(String nom) {
|
||||||
this.nom = nom;
|
this.nom = nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTaille(double taille) {
|
public void setTaille(double taille) {
|
||||||
this.taille = taille;
|
this.taille = taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPoids(double poids) {
|
public void setPoids(double poids) {
|
||||||
this.poids = poids;
|
this.poids = poids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPv(int pv) {
|
public void setPv(int pv) {
|
||||||
this.pv = pv;
|
this.pv = pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPc(int pc) {
|
public void setPc(int pc) {
|
||||||
this.pc = pc;
|
this.pc = pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(Type type) {
|
public void setType(Type type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
96
TD9/src/pokemon/PokemonEAU.java → src/TD10/pokemon/PokemonEAU.java
Executable file → Normal file
96
TD9/src/pokemon/PokemonEAU.java → src/TD10/pokemon/PokemonEAU.java
Executable file → Normal file
@ -1,48 +1,48 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class PokemonEAU extends Pokemon{
|
public class PokemonEAU extends Pokemon{
|
||||||
private int nb_nageoires;
|
private int nb_nageoires;
|
||||||
|
|
||||||
public PokemonEAU(String n, double t, double p, int pv, int pc, int g) {
|
public PokemonEAU(String n, double t, double p, int pv, int pc, int g) {
|
||||||
super.setNom(n);
|
super.setNom(n);
|
||||||
super.setTaille(t);
|
super.setTaille(t);
|
||||||
super.setPoids(p);
|
super.setPoids(p);
|
||||||
super.setPv(pv);
|
super.setPv(pv);
|
||||||
super.setPc(pc);
|
super.setPc(pc);
|
||||||
this.type = Type.EAU;
|
this.type = Type.EAU;
|
||||||
nb_nageoires = g;
|
nb_nageoires = g;
|
||||||
}
|
}
|
||||||
public int getNb_nageoires() {
|
public int getNb_nageoires() {
|
||||||
return nb_nageoires;
|
return nb_nageoires;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
this.setPv(Math.max(0, this.getPv() - modif));
|
this.setPv(Math.max(0, this.getPv() - modif));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return (this.getPoids() * nb_nageoires) / 25.0;
|
return (this.getPoids() * nb_nageoires) / 25.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.getNom();
|
return this.getNom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
if(p2.type == Type.ELECTRIK) {
|
if(p2.type == Type.ELECTRIK) {
|
||||||
p2.setPv(p2.getPv()-this.getPc());
|
p2.setPv(p2.getPv()-this.getPc());
|
||||||
}
|
}
|
||||||
else if(p2.type == Type.FEU) {
|
else if(p2.type == Type.FEU) {
|
||||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
112
TD8/src/pokemon/PokemonELECTRIK.java → src/TD10/pokemon/PokemonELECTRIK.java
Executable file → Normal file
112
TD8/src/pokemon/PokemonELECTRIK.java → src/TD10/pokemon/PokemonELECTRIK.java
Executable file → Normal file
@ -1,56 +1,56 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class PokemonELECTRIK extends Pokemon {
|
public class PokemonELECTRIK extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
private int nb_ailes;
|
private int nb_ailes;
|
||||||
private double intensite;
|
private double intensite;
|
||||||
|
|
||||||
public PokemonELECTRIK(String n, double t, double p, int pv, int pc, int g, int a, double i) {
|
public PokemonELECTRIK(String n, double t, double p, int pv, int pc, int g, int a, double i) {
|
||||||
super.setNom(n);
|
super.setNom(n);
|
||||||
super.setTaille(t);
|
super.setTaille(t);
|
||||||
super.setPoids(p);
|
super.setPoids(p);
|
||||||
super.setPv(pv);
|
super.setPv(pv);
|
||||||
super.setPc(pc);
|
super.setPc(pc);
|
||||||
this.type = Type.ELECTRIK;
|
this.type = Type.ELECTRIK;
|
||||||
nb_pattes = g;
|
nb_pattes = g;
|
||||||
nb_ailes = a;
|
nb_ailes = a;
|
||||||
intensite = i;
|
intensite = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPattes() {
|
public int getPattes() {
|
||||||
return nb_pattes;
|
return nb_pattes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAiles() {
|
public int getAiles() {
|
||||||
return nb_ailes;
|
return nb_ailes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getIntensite() {
|
public double getIntensite() {
|
||||||
return intensite;
|
return intensite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
this.setPv(Math.max(0, this.getPv() - modif));
|
this.setPv(Math.max(0, this.getPv() - modif));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return (nb_ailes + nb_pattes) * intensite * 0.05;
|
return (nb_ailes + nb_pattes) * intensite * 0.05;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.getNom();
|
return this.getNom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
if (p2.type == Type.FEU) {
|
if (p2.type == Type.FEU) {
|
||||||
p2.setPv(p2.getPv() - this.getPc());
|
p2.setPv(p2.getPv() - this.getPc());
|
||||||
} else if (p2.type == Type.EAU) {
|
} else if (p2.type == Type.EAU) {
|
||||||
p2.setPv((p2.getPv() - this.getPc() * 2));
|
p2.setPv((p2.getPv() - this.getPc() * 2));
|
||||||
} else {
|
} else {
|
||||||
p2.setPv((p2.getPv() - this.getPc() / 2));
|
p2.setPv((p2.getPv() - this.getPc() / 2));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
94
TD9/src/pokemon/PokemonFEU.java → src/TD10/pokemon/PokemonFEU.java
Executable file → Normal file
94
TD9/src/pokemon/PokemonFEU.java → src/TD10/pokemon/PokemonFEU.java
Executable file → Normal file
@ -1,47 +1,47 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class PokemonFEU extends Pokemon {
|
public class PokemonFEU extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
|
||||||
public PokemonFEU(String n, double t, double p, int pv, int pc, int g) {
|
public PokemonFEU(String n, double t, double p, int pv, int pc, int g) {
|
||||||
super.setNom(n);
|
super.setNom(n);
|
||||||
super.setTaille(t);
|
super.setTaille(t);
|
||||||
super.setPoids(p);
|
super.setPoids(p);
|
||||||
super.setPv(pv);
|
super.setPv(pv);
|
||||||
super.setPc(pc);
|
super.setPc(pc);
|
||||||
this.type = Type.FEU;
|
this.type = Type.FEU;
|
||||||
nb_pattes = g;
|
nb_pattes = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPattes() {
|
public int getPattes() {
|
||||||
return nb_pattes;
|
return nb_pattes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
this.setPv(Math.max(0, this.getPv() - modif));
|
this.setPv(Math.max(0, this.getPv() - modif));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return this.getPoids() * nb_pattes * 0.03;
|
return this.getPoids() * nb_pattes * 0.03;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.getNom();
|
return this.getNom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
if(p2.type == Type.FEU) {
|
if(p2.type == Type.FEU) {
|
||||||
p2.setPv(p2.getPv()-this.getPc());
|
p2.setPv(p2.getPv()-this.getPc());
|
||||||
}
|
}
|
||||||
else if(p2.type == Type.PLANTE) {
|
else if(p2.type == Type.PLANTE) {
|
||||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
80
TD10/src/pokemon/PokemonPLANTE.java → src/TD10/pokemon/PokemonPLANTE.java
Executable file → Normal file
80
TD10/src/pokemon/PokemonPLANTE.java → src/TD10/pokemon/PokemonPLANTE.java
Executable file → Normal file
@ -1,41 +1,41 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class PokemonPLANTE extends Pokemon{
|
public class PokemonPLANTE extends Pokemon{
|
||||||
|
|
||||||
public PokemonPLANTE(String n, double t, double p, int pv, int pc) {
|
public PokemonPLANTE(String n, double t, double p, int pv, int pc) {
|
||||||
super.setNom(n);
|
super.setNom(n);
|
||||||
super.setTaille(t);
|
super.setTaille(t);
|
||||||
super.setPoids(p);
|
super.setPoids(p);
|
||||||
super.setPv(pv);
|
super.setPv(pv);
|
||||||
super.setPc(pc);
|
super.setPc(pc);
|
||||||
this.type = Type.PLANTE;
|
this.type = Type.PLANTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
this.setPv(Math.max(0, this.getPv() - modif));
|
this.setPv(Math.max(0, this.getPv() - modif));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return 10.0 / (this.getPoids() * this.getTaille());
|
return 10.0 / (this.getPoids() * this.getTaille());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.getNom();
|
return this.getNom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
if(p2.type == Type.EAU) {
|
if(p2.type == Type.EAU) {
|
||||||
p2.setPv(p2.getPv()-this.getPc());
|
p2.setPv(p2.getPv()-this.getPc());
|
||||||
}
|
}
|
||||||
else if(p2.type == Type.ELECTRIK) {
|
else if(p2.type == Type.ELECTRIK) {
|
||||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
212
TD9/src/pokemon/TestPokemon.java → src/TD10/pokemon/TestPokemon.java
Executable file → Normal file
212
TD9/src/pokemon/TestPokemon.java → src/TD10/pokemon/TestPokemon.java
Executable file → Normal file
@ -1,106 +1,106 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class TestPokemon {
|
public class TestPokemon {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
//fire
|
//fire
|
||||||
PokemonFEU Infernape = new PokemonFEU("Infernape", 1.2, 55., 356, 45, 4);
|
PokemonFEU Infernape = new PokemonFEU("Infernape", 1.2, 55., 356, 45, 4);
|
||||||
PokemonFEU Ninetales = new PokemonFEU("Ninetales", 1.1, 19.9, 350, 26, 4);
|
PokemonFEU Ninetales = new PokemonFEU("Ninetales", 1.1, 19.9, 350, 26, 4);
|
||||||
PokemonFEU Salameche = new PokemonFEU("Salameche",0.5,5.,50,10,4);
|
PokemonFEU Salameche = new PokemonFEU("Salameche",0.5,5.,50,10,4);
|
||||||
|
|
||||||
//Electric
|
//Electric
|
||||||
PokemonELECTRIK Ampharos = new PokemonELECTRIK("Ampharos", 1.4, 61.5, 384, 32, 2, 0, 95);
|
PokemonELECTRIK Ampharos = new PokemonELECTRIK("Ampharos", 1.4, 61.5, 384, 32, 2, 0, 95);
|
||||||
PokemonELECTRIK RaichuA = new PokemonELECTRIK("Raichu Alolan Form", .7, 21., 324, 37, 2, 0, 105);
|
PokemonELECTRIK RaichuA = new PokemonELECTRIK("Raichu Alolan Form", .7, 21., 324, 37, 2, 0, 105);
|
||||||
PokemonELECTRIK Voltali = new PokemonELECTRIK("Voltali", 1.8, 47.3, 120, 130, 4, 0, 12);
|
PokemonELECTRIK Voltali = new PokemonELECTRIK("Voltali", 1.8, 47.3, 120, 130, 4, 0, 12);
|
||||||
PokemonELECTRIK Pikachu = new PokemonELECTRIK("Pikachu", 0.9, 5.3, 90, 50, 4, 0, 12);
|
PokemonELECTRIK Pikachu = new PokemonELECTRIK("Pikachu", 0.9, 5.3, 90, 50, 4, 0, 12);
|
||||||
|
|
||||||
//water
|
//water
|
||||||
PokemonEAU Ludicolo = new PokemonEAU("Ludicolo", 1.5, 55., 364, 45, 2);
|
PokemonEAU Ludicolo = new PokemonEAU("Ludicolo", 1.5, 55., 364, 45, 2);
|
||||||
PokemonEAU Froakie = new PokemonEAU("Froakie", .3, 7., 286, 20, 2);
|
PokemonEAU Froakie = new PokemonEAU("Froakie", .3, 7., 286, 20, 2);
|
||||||
PokemonEAU Aquali = new PokemonEAU("Aquali", 2.1, 56.3, 140, 90, 3);
|
PokemonEAU Aquali = new PokemonEAU("Aquali", 2.1, 56.3, 140, 90, 3);
|
||||||
PokemonEAU Carapuce = new PokemonEAU("Carapuce",0.5,5.,50,10,0);
|
PokemonEAU Carapuce = new PokemonEAU("Carapuce",0.5,5.,50,10,0);
|
||||||
|
|
||||||
//grass
|
//grass
|
||||||
PokemonPLANTE Roselia = new PokemonPLANTE("Roselia", .3, 2., 304, 14);
|
PokemonPLANTE Roselia = new PokemonPLANTE("Roselia", .3, 2., 304, 14);
|
||||||
PokemonPLANTE Torterra = new PokemonPLANTE("Torterra", 2.2, 310., 394, 44);
|
PokemonPLANTE Torterra = new PokemonPLANTE("Torterra", 2.2, 310., 394, 44);
|
||||||
PokemonPLANTE Phylali = new PokemonPLANTE("Phylali", 1.6, 28.5, 130, 70);
|
PokemonPLANTE Phylali = new PokemonPLANTE("Phylali", 1.6, 28.5, 130, 70);
|
||||||
PokemonPLANTE Herbizarre = new PokemonPLANTE("Herbizarre",0.5,5.,50,10);
|
PokemonPLANTE Herbizarre = new PokemonPLANTE("Herbizarre",0.5,5.,50,10);
|
||||||
|
|
||||||
Joueur JunkJumper = new Joueur("JunkJumper");
|
Joueur JunkJumper = new Joueur("JunkJumper");
|
||||||
Joueur Mkel = new Joueur("Mkel");
|
Joueur Mkel = new Joueur("Mkel");
|
||||||
|
|
||||||
ArrayList<Pokemon> l1 = new ArrayList<Pokemon>();
|
ArrayList<Pokemon> l1 = new ArrayList<Pokemon>();
|
||||||
ArrayList<Pokemon> l2 = new ArrayList<Pokemon>();
|
ArrayList<Pokemon> l2 = new ArrayList<Pokemon>();
|
||||||
|
|
||||||
l1.add(Infernape);
|
l1.add(Infernape);
|
||||||
l1.add(Ludicolo);
|
l1.add(Ludicolo);
|
||||||
l1.add(Roselia);
|
l1.add(Roselia);
|
||||||
l1.add(Ampharos);
|
l1.add(Ampharos);
|
||||||
|
|
||||||
l2.add(Voltali);
|
l2.add(Voltali);
|
||||||
l2.add(Salameche);
|
l2.add(Salameche);
|
||||||
l2.add(Froakie);
|
l2.add(Froakie);
|
||||||
l2.add(Herbizarre);
|
l2.add(Herbizarre);
|
||||||
l2.add(Torterra);
|
l2.add(Torterra);
|
||||||
l2.add(Carapuce);
|
l2.add(Carapuce);
|
||||||
l2.add(Ninetales);
|
l2.add(Ninetales);
|
||||||
|
|
||||||
JunkJumper.setPokemon(l1);
|
JunkJumper.setPokemon(l1);
|
||||||
Mkel.setPokemon(l2);
|
Mkel.setPokemon(l2);
|
||||||
|
|
||||||
System.out.println("===== Collection 1 : =====");;
|
System.out.println("===== Collection 1 : =====");;
|
||||||
for (Pokemon pokemon : l1) {
|
for (Pokemon pokemon : l1) {
|
||||||
System.out.println(pokemon.toString());
|
System.out.println(pokemon.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("===== Collection 2 : =====");;
|
System.out.println("===== Collection 2 : =====");;
|
||||||
for (Pokemon pokemon : l2) {
|
for (Pokemon pokemon : l2) {
|
||||||
System.out.println(pokemon.toString());
|
System.out.println(pokemon.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(l1);
|
Collections.sort(l1);
|
||||||
Collections.sort(l2);
|
Collections.sort(l2);
|
||||||
|
|
||||||
JunkJumper.setNiveau(4);
|
JunkJumper.setNiveau(4);
|
||||||
Mkel.setNiveau(7);
|
Mkel.setNiveau(7);
|
||||||
|
|
||||||
System.out.println("\n Tri par nom effectue");
|
System.out.println("\n Tri par nom effectue");
|
||||||
|
|
||||||
System.out.println("===== Collection 1 : =====");;
|
System.out.println("===== Collection 1 : =====");;
|
||||||
for (Pokemon pokemon : l1) {
|
for (Pokemon pokemon : l1) {
|
||||||
System.out.println(pokemon.toString());
|
System.out.println(pokemon.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("===== Collection 2 : =====");;
|
System.out.println("===== Collection 2 : =====");;
|
||||||
for (Pokemon pokemon : l2) {
|
for (Pokemon pokemon : l2) {
|
||||||
System.out.println(pokemon.toString());
|
System.out.println(pokemon.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Joueur> lj = new ArrayList<Joueur>();
|
ArrayList<Joueur> lj = new ArrayList<Joueur>();
|
||||||
|
|
||||||
lj.add(JunkJumper);
|
lj.add(JunkJumper);
|
||||||
lj.add(Mkel);
|
lj.add(Mkel);
|
||||||
|
|
||||||
for (Joueur joueur : lj) {
|
for (Joueur joueur : lj) {
|
||||||
System.out.println(joueur.toString());
|
System.out.println(joueur.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(lj);
|
Collections.sort(lj);
|
||||||
System.out.println("\n Tri par nom effectue");
|
System.out.println("\n Tri par nom effectue");
|
||||||
for (Joueur joueur : lj) {
|
for (Joueur joueur : lj) {
|
||||||
System.out.println(joueur.toString());
|
System.out.println(joueur.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Hello Pokeworld !");
|
System.out.println("Hello Pokeworld !");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
38
TD8/src/pokemon/Type.java → src/TD10/pokemon/Type.java
Executable file → Normal file
38
TD8/src/pokemon/Type.java → src/TD10/pokemon/Type.java
Executable file → Normal file
@ -1,19 +1,19 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
|
|
||||||
EAU("EAU"),
|
EAU("EAU"),
|
||||||
ELECTRIK("ELECTRIK"),
|
ELECTRIK("ELECTRIK"),
|
||||||
FEU("FEU"),
|
FEU("FEU"),
|
||||||
PLANTE("PLANTE");
|
PLANTE("PLANTE");
|
||||||
|
|
||||||
Type(String s) {
|
Type(String s) {
|
||||||
description = s;
|
description = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
}
|
}
|
78024
TD10/-France_Codepostal_2009.txt → src/TD10/txt/-France_Codepostal_2009.txt
Executable file → Normal file
78024
TD10/-France_Codepostal_2009.txt → src/TD10/txt/-France_Codepostal_2009.txt
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
0
TD10/-France_Codepostal_2009_esp.txt → src/TD10/txt/-France_Codepostal_2009_esp.txt
Executable file → Normal file
0
TD10/-France_Codepostal_2009_esp.txt → src/TD10/txt/-France_Codepostal_2009_esp.txt
Executable file → Normal file
212
TD10/-ListePokemon.txt → src/TD10/txt/-ListePokemon.txt
Executable file → Normal file
212
TD10/-ListePokemon.txt → src/TD10/txt/-ListePokemon.txt
Executable file → Normal file
@ -1,106 +1,106 @@
|
|||||||
Bulbizarre Plante 0.7 6.9 294 62
|
Bulbizarre Plante 0.7 6.9 294 62
|
||||||
Herbizarre Plante 1.0 13.0 324 74
|
Herbizarre Plante 1.0 13.0 324 74
|
||||||
Florizarre Plante 2.0 100.0 364 92
|
Florizarre Plante 2.0 100.0 364 92
|
||||||
Salameche Feu 0.6 8.5 282 65 4
|
Salameche Feu 0.6 8.5 282 65 4
|
||||||
Reptincel Feu 1.1 19.0 320 76 4
|
Reptincel Feu 1.1 19.0 320 76 4
|
||||||
Dracaufeu Feu 1.7 90.5 360 94 4
|
Dracaufeu Feu 1.7 90.5 360 94 4
|
||||||
Carapuce Eau 0.5 9.0 292 61 4
|
Carapuce Eau 0.5 9.0 292 61 4
|
||||||
Carabaffe Eau 1.0 22.5 322 75 4
|
Carabaffe Eau 1.0 22.5 322 75 4
|
||||||
Tortank Eau 1.8 85.5 362 93 4
|
Tortank Eau 1.8 85.5 362 93 4
|
||||||
Pikachu Electrik 0.4 6.0 274 67 4 0 50
|
Pikachu Electrik 0.4 6.0 274 67 4 0 50
|
||||||
Raichu Electrik 0.8 30.0 324 99 4 0 90
|
Raichu Electrik 0.8 30.0 324 99 4 0 90
|
||||||
Goupix Feu 0.6 9.9 280 55 4
|
Goupix Feu 0.6 9.9 280 55 4
|
||||||
Feunard Feu 1.1 19.9 350 86 4
|
Feunard Feu 1.1 19.9 350 86 4
|
||||||
Mystherbe Plante 0.5 5.4 294 63
|
Mystherbe Plante 0.5 5.4 294 63
|
||||||
Ortide Plante 0.8 8.6 324 76
|
Ortide Plante 0.8 8.6 324 76
|
||||||
Rafflesia Plante 1.2 18.6 354 90
|
Rafflesia Plante 1.2 18.6 354 90
|
||||||
Paras Plante 0.3 5.4 274 81
|
Paras Plante 0.3 5.4 274 81
|
||||||
Parasect Plante 1.0 29.5 324 103
|
Parasect Plante 1.0 29.5 324 103
|
||||||
Psykokwak Eau 0.8 19.6 304 65 4
|
Psykokwak Eau 0.8 19.6 304 65 4
|
||||||
Akwakwak Eau 1.7 76.6 364 92 4
|
Akwakwak Eau 1.7 76.6 364 92 4
|
||||||
Caninos Feu 0.7 19.0 314 81 4
|
Caninos Feu 0.7 19.0 314 81 4
|
||||||
Arcanin Feu 1.9 155.0 384 117 4
|
Arcanin Feu 1.9 155.0 384 117 4
|
||||||
Ptitard Eau 0.6 12.4 284 63 3
|
Ptitard Eau 0.6 12.4 284 63 3
|
||||||
Tetarte Eau 1.0 20.0 334 76 4
|
Tetarte Eau 1.0 20.0 334 76 4
|
||||||
Tartard Eau 1.3 54.0 384 94 4
|
Tartard Eau 1.3 54.0 384 94 4
|
||||||
Chetiflor Plante 0.7 4.0 304 85
|
Chetiflor Plante 0.7 4.0 304 85
|
||||||
Boustiflor Plante 1.0 6.4 334 99
|
Boustiflor Plante 1.0 6.4 334 99
|
||||||
Empiflor Plante 1.7 15.5 364 112
|
Empiflor Plante 1.7 15.5 364 112
|
||||||
Tentacool Eau 0.9 45.5 284 54 2
|
Tentacool Eau 0.9 45.5 284 54 2
|
||||||
Tentacruel Eau 1.6 55.0 364 81 6
|
Tentacruel Eau 1.6 55.0 364 81 6
|
||||||
Ponyta Feu 1.0 30.0 304 94 4
|
Ponyta Feu 1.0 30.0 304 94 4
|
||||||
Galopa Feu 1.7 95.0 334 108 4
|
Galopa Feu 1.7 95.0 334 108 4
|
||||||
Ramoloss Eau 1.2 36.0 384 76 5
|
Ramoloss Eau 1.2 36.0 384 76 5
|
||||||
Flagadoss Eau 1.6 78.5 394 85 5
|
Flagadoss Eau 1.6 78.5 394 85 5
|
||||||
Magneti Electrik 0.3 6.0 254 49 0 2 95
|
Magneti Electrik 0.3 6.0 254 49 0 2 95
|
||||||
Magneton Electrik 1.0 60.0 304 72 0 6 120
|
Magneton Electrik 1.0 60.0 304 72 0 6 120
|
||||||
Otaria Eau 1.1 90.0 334 58 3
|
Otaria Eau 1.1 90.0 334 58 3
|
||||||
Lamantine Eau 1.7 120.0 384 81 3
|
Lamantine Eau 1.7 120.0 384 81 3
|
||||||
Kokiyas Eau 0.3 4.0 264 76 0
|
Kokiyas Eau 0.3 4.0 264 76 0
|
||||||
Crustabri Eau 1.5 132.5 304 103 0
|
Crustabri Eau 1.5 132.5 304 103 0
|
||||||
Kraby Eau 0.4 6.5 264 112 2
|
Kraby Eau 0.4 6.5 264 112 2
|
||||||
Krabboss Eau 1.3 60.0 314 135 2
|
Krabboss Eau 1.3 60.0 314 135 2
|
||||||
Voltorbe Electrik 0.5 10.4 284 45 0 1 55
|
Voltorbe Electrik 0.5 10.4 284 45 0 1 55
|
||||||
Electrode Electrik 1.2 66.6 324 63 0 1 80
|
Electrode Electrik 1.2 66.6 324 63 0 1 80
|
||||||
Noeunoeuf Plante 0.4 2.5 324 54
|
Noeunoeuf Plante 0.4 2.5 324 54
|
||||||
Noadkoko Plante 2.0 120.0 394 103
|
Noadkoko Plante 2.0 120.0 394 103
|
||||||
Saquedeneu Plante 1.0 35.0 334 67
|
Saquedeneu Plante 1.0 35.0 334 67
|
||||||
Hypotrempe Eau 0.4 8.0 264 54 1
|
Hypotrempe Eau 0.4 8.0 264 54 1
|
||||||
Hypocean Eau 1.2 25.0 314 76 1
|
Hypocean Eau 1.2 25.0 314 76 1
|
||||||
Poissirene Eau 0.6 15.0 294 78 3
|
Poissirene Eau 0.6 15.0 294 78 3
|
||||||
Poissoroy Eau 1.3 39.0 364 101 3
|
Poissoroy Eau 1.3 39.0 364 101 3
|
||||||
Stari Eau 0.8 34.5 264 58 1
|
Stari Eau 0.8 34.5 264 58 1
|
||||||
Staross Eau 1.1 80.0 324 85 1
|
Staross Eau 1.1 80.0 324 85 1
|
||||||
Elektek Electrik 1.1 30.0 334 93 4 0 95
|
Elektek Electrik 1.1 30.0 334 93 4 0 95
|
||||||
Magmar Feu 1.3 44.5 334 103 4
|
Magmar Feu 1.3 44.5 334 103 4
|
||||||
Magicarpe Eau 0.9 10.0 244 27 3
|
Magicarpe Eau 0.9 10.0 244 27 3
|
||||||
Leviator Eau 6.5 235.0 394 130 1
|
Leviator Eau 6.5 235.0 394 130 1
|
||||||
Lokhlass Eau 2.5 220.0 464 94 2
|
Lokhlass Eau 2.5 220.0 464 94 2
|
||||||
Aquali Eau 1.0 29.0 464 76 7
|
Aquali Eau 1.0 29.0 464 76 7
|
||||||
Voltali Electrik 0.8 24.5 334 76 4 0 110
|
Voltali Electrik 0.8 24.5 334 76 4 0 110
|
||||||
Pyroli Feu 0.9 25.9 334 135 4
|
Pyroli Feu 0.9 25.9 334 135 4
|
||||||
Amonita Eau 0.4 7.5 274 54 2
|
Amonita Eau 0.4 7.5 274 54 2
|
||||||
Amonistar Eau 1.0 35.0 344 72 4
|
Amonistar Eau 1.0 35.0 344 72 4
|
||||||
Kabuto Eau 0.5 11.5 264 90 1
|
Kabuto Eau 0.5 11.5 264 90 1
|
||||||
Kabutops Eau 1.3 40.5 324 121 2
|
Kabutops Eau 1.3 40.5 324 121 2
|
||||||
Electhor Electrik 1.6 52.6 384 99 2 2 125
|
Electhor Electrik 1.6 52.6 384 99 2 2 125
|
||||||
Sulfura Feu 2.0 60.0 384 108 2
|
Sulfura Feu 2.0 60.0 384 108 2
|
||||||
Germignon Plante 0.9 6.4 294 62
|
Germignon Plante 0.9 6.4 294 62
|
||||||
Macronium Plante 1.2 15.8 324 74
|
Macronium Plante 1.2 15.8 324 74
|
||||||
Meganium Plante 1.8 100.5 364 92
|
Meganium Plante 1.8 100.5 364 92
|
||||||
Hericendre Feu 0.5 7.9 282 65 4
|
Hericendre Feu 0.5 7.9 282 65 4
|
||||||
Feurisson Feu 0.9 19.0 320 76 4
|
Feurisson Feu 0.9 19.0 320 76 4
|
||||||
Typhlosion Feu 1.7 79.5 360 94 4
|
Typhlosion Feu 1.7 79.5 360 94 4
|
||||||
Kaiminus Eau 0.6 9.5 304 76 4
|
Kaiminus Eau 0.6 9.5 304 76 4
|
||||||
Crocrodil Eau 1.1 25.0 334 90 4
|
Crocrodil Eau 1.1 25.0 334 90 4
|
||||||
Aligatueur Eau 2.3 88.8 374 112 4
|
Aligatueur Eau 2.3 88.8 374 112 4
|
||||||
Loupio Electrik 0.5 12.0 354 52 2 2 56
|
Loupio Electrik 0.5 12.0 354 52 2 2 56
|
||||||
Lanturn Electrik 1.2 22.5 454 70 0 2 76
|
Lanturn Electrik 1.2 22.5 454 70 0 2 76
|
||||||
Pichu Electrik 0.3 2.0 244 54 4 0 35
|
Pichu Electrik 0.3 2.0 244 54 4 0 35
|
||||||
Wattouat Electrik 0.6 7.8 314 54 4 0 65
|
Wattouat Electrik 0.6 7.8 314 54 4 0 65
|
||||||
Lainergie Electrik 0.8 13.3 344 67 4 0 80
|
Lainergie Electrik 0.8 13.3 344 67 4 0 80
|
||||||
Pharamp Electrik 1.4 61.5 384 85 4 0 115
|
Pharamp Electrik 1.4 61.5 384 85 4 0 115
|
||||||
Joliflor Plante 0.4 5.8 354 90
|
Joliflor Plante 0.4 5.8 354 90
|
||||||
Marill Eau 0.4 8.5 344 36 4
|
Marill Eau 0.4 8.5 344 36 4
|
||||||
Azumarill Eau 0.8 28.5 404 63 6
|
Azumarill Eau 0.8 28.5 404 63 6
|
||||||
Tarpaud Eau 1.1 33.9 383 85 4
|
Tarpaud Eau 1.1 33.9 383 85 4
|
||||||
Granivol Plante 0.4 0.5 274 49
|
Granivol Plante 0.4 0.5 274 49
|
||||||
Floravol Plante 0.6 1.0 314 58
|
Floravol Plante 0.6 1.0 314 58
|
||||||
Cotovol Plante 0.8 3.0 354 67
|
Cotovol Plante 0.8 3.0 354 67
|
||||||
Tournegrin Plante 0.3 1.8 264 45
|
Tournegrin Plante 0.3 1.8 264 45
|
||||||
Heliatronc Plante 0.8 8.5 354 85
|
Heliatronc Plante 0.8 8.5 354 85
|
||||||
Axoloto Eau 0.4 8.5 314 58 2
|
Axoloto Eau 0.4 8.5 314 58 2
|
||||||
Maraiste Eau 1.4 75.0 394 94 4
|
Maraiste Eau 1.4 75.0 394 94 4
|
||||||
Roigada Eau 2.0 79.5 394 85 3
|
Roigada Eau 2.0 79.5 394 85 3
|
||||||
Qwilfish Eau 0.5 3.9 334 103 1
|
Qwilfish Eau 0.5 3.9 334 103 1
|
||||||
Limagma Feu 0.7 35.0 284 54 2
|
Limagma Feu 0.7 35.0 284 54 2
|
||||||
Volcaropod Feu 0.8 55.0 304 63 2
|
Volcaropod Feu 0.8 55.0 304 63 2
|
||||||
Corayon Eau 0.6 5.0 314 67 0
|
Corayon Eau 0.6 5.0 314 67 0
|
||||||
Remoraid Eau 0.6 12.0 274 76 2
|
Remoraid Eau 0.6 12.0 274 76 2
|
||||||
Octillery Eau 0.9 28.5 354 112 2
|
Octillery Eau 0.9 28.5 354 112 2
|
||||||
Demanta Eau 2.1 220.0 334 54 2
|
Demanta Eau 2.1 220.0 334 54 2
|
||||||
Malosse Feu 0.6 10.8 294 72 4
|
Malosse Feu 0.6 10.8 294 72 4
|
||||||
Demolosse Feu 1.4 35.0 354 99 4
|
Demolosse Feu 1.4 35.0 354 99 4
|
||||||
Hyporoi Eau 1.8 152.0 354 103 1
|
Hyporoi Eau 1.8 152.0 354 103 1
|
||||||
Elekid Electrik 0.6 23.5 294 75 4 0 65
|
Elekid Electrik 0.6 23.5 294 75 4 0 65
|
||||||
Magby Feu 0.7 21.4 294 85 4
|
Magby Feu 0.7 21.4 294 85 4
|
0
TD10/France_Code_Postal_2009.txt → src/TD10/txt/France_Code_Postal_2009.txt
Executable file → Normal file
0
TD10/France_Code_Postal_2009.txt → src/TD10/txt/France_Code_Postal_2009.txt
Executable file → Normal file
0
TD10/France_Code_Postal_2009ESP.txt → src/TD10/txt/France_Code_Postal_2009ESP.txt
Executable file → Normal file
0
TD10/France_Code_Postal_2009ESP.txt → src/TD10/txt/France_Code_Postal_2009ESP.txt
Executable file → Normal file
0
TD10/France_Communes_2009.txt → src/TD10/txt/France_Communes_2009.txt
Executable file → Normal file
0
TD10/France_Communes_2009.txt → src/TD10/txt/France_Communes_2009.txt
Executable file → Normal file
77780
TD10/France_Communes_2009ESP.txt → src/TD10/txt/France_Communes_2009ESP.txt
Executable file → Normal file
77780
TD10/France_Communes_2009ESP.txt → src/TD10/txt/France_Communes_2009ESP.txt
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
142
TD2/src/ensembleEntierBorne/EnsembleEntierBorne.java → src/TD2/ensembleEntierBorne/EnsembleEntierBorne.java
Executable file → Normal file
142
TD2/src/ensembleEntierBorne/EnsembleEntierBorne.java → src/TD2/ensembleEntierBorne/EnsembleEntierBorne.java
Executable file → Normal file
@ -1,71 +1,71 @@
|
|||||||
package ensembleEntierBorne;
|
package ensembleEntierBorne;
|
||||||
|
|
||||||
public class EnsembleEntierBorne {
|
public class EnsembleEntierBorne {
|
||||||
|
|
||||||
private final int MAXIMUM;
|
private final int MAXIMUM;
|
||||||
private boolean tab[];
|
private boolean tab[];
|
||||||
|
|
||||||
public EnsembleEntierBorne(int max)
|
public EnsembleEntierBorne(int max)
|
||||||
{
|
{
|
||||||
MAXIMUM = max;
|
MAXIMUM = max;
|
||||||
tab = new boolean[max+1];
|
tab = new boolean[max+1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(int elt)
|
public void add(int elt)
|
||||||
{
|
{
|
||||||
this.tab[elt] = true;
|
this.tab[elt] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(int elt)
|
public void remove(int elt)
|
||||||
{
|
{
|
||||||
this.tab[elt] = false;
|
this.tab[elt] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean doesContains(int elt)
|
public boolean doesContains(int elt)
|
||||||
{
|
{
|
||||||
if (this.tab[elt] == true) {
|
if (this.tab[elt] == true) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*EnsembleEntierBorne intersect(EnsembleEntierBorne ens)
|
/*EnsembleEntierBorne intersect(EnsembleEntierBorne ens)
|
||||||
{
|
{
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public int getMAXIMUM() {
|
public int getMAXIMUM() {
|
||||||
return MAXIMUM;
|
return MAXIMUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean[] getTab() {
|
public boolean[] getTab() {
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTab(boolean tab[]) {
|
public void setTab(boolean tab[]) {
|
||||||
this.tab = tab;
|
this.tab = tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
String retour = "{";
|
String retour = "{";
|
||||||
|
|
||||||
for (int i = 0; i < this.MAXIMUM; i++)
|
for (int i = 0; i < this.MAXIMUM; i++)
|
||||||
{
|
{
|
||||||
if (this.tab[i] == true)
|
if (this.tab[i] == true)
|
||||||
{
|
{
|
||||||
retour += i+", ";
|
retour += i+", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
retour += "}";
|
retour += "}";
|
||||||
return retour;
|
return retour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
92
TD2/src/ensembleEntierBorne/TestEnsembleEntierBorne.java → src/TD2/ensembleEntierBorne/TestEnsembleEntierBorne.java
Executable file → Normal file
92
TD2/src/ensembleEntierBorne/TestEnsembleEntierBorne.java → src/TD2/ensembleEntierBorne/TestEnsembleEntierBorne.java
Executable file → Normal file
@ -1,46 +1,46 @@
|
|||||||
package ensembleEntierBorne;
|
package ensembleEntierBorne;
|
||||||
|
|
||||||
public class TestEnsembleEntierBorne {
|
public class TestEnsembleEntierBorne {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
EnsembleEntierBorne e1 = new EnsembleEntierBorne(20);
|
EnsembleEntierBorne e1 = new EnsembleEntierBorne(20);
|
||||||
EnsembleEntierBorne e2 = new EnsembleEntierBorne(11);
|
EnsembleEntierBorne e2 = new EnsembleEntierBorne(11);
|
||||||
EnsembleEntierBorne e3 = new EnsembleEntierBorne(5);
|
EnsembleEntierBorne e3 = new EnsembleEntierBorne(5);
|
||||||
|
|
||||||
e1.add(3);
|
e1.add(3);
|
||||||
e1.add(5);
|
e1.add(5);
|
||||||
e1.add(9);
|
e1.add(9);
|
||||||
e1.add(14);
|
e1.add(14);
|
||||||
e1.add(18);
|
e1.add(18);
|
||||||
e1.add(18);
|
e1.add(18);
|
||||||
|
|
||||||
System.out.println(e1.toString());
|
System.out.println(e1.toString());
|
||||||
|
|
||||||
e1.remove(3);
|
e1.remove(3);
|
||||||
e1.remove(18);
|
e1.remove(18);
|
||||||
|
|
||||||
System.out.println(e1.toString());
|
System.out.println(e1.toString());
|
||||||
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
e2.add(1);
|
e2.add(1);
|
||||||
e2.add(2);
|
e2.add(2);
|
||||||
e2.add(3);
|
e2.add(3);
|
||||||
e2.add(4);
|
e2.add(4);
|
||||||
e2.add(5);
|
e2.add(5);
|
||||||
e2.add(6);
|
e2.add(6);
|
||||||
e2.add(7);
|
e2.add(7);
|
||||||
e2.add(8);
|
e2.add(8);
|
||||||
|
|
||||||
e3.add(5);
|
e3.add(5);
|
||||||
e3.add(0);
|
e3.add(0);
|
||||||
e3.add(3);
|
e3.add(3);
|
||||||
|
|
||||||
System.out.println("e1 = " + e1.toString());
|
System.out.println("e1 = " + e1.toString());
|
||||||
System.out.println("e2 = " + e2.toString());
|
System.out.println("e2 = " + e2.toString());
|
||||||
System.out.println("e3 = " + e3.toString());
|
System.out.println("e3 = " + e3.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
186
TD2/src/test/TestTriplet.java → src/TD2/test/TestTriplet.java
Executable file → Normal file
186
TD2/src/test/TestTriplet.java → src/TD2/test/TestTriplet.java
Executable file → Normal file
@ -1,93 +1,93 @@
|
|||||||
package test;
|
package test;
|
||||||
import tripletEntier.TripletEntier;
|
import tripletEntier.TripletEntier;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class TestTriplet {
|
class TestTriplet {
|
||||||
|
|
||||||
private TripletEntier t1 = new TripletEntier(4, 3, 3);
|
private TripletEntier t1 = new TripletEntier(4, 3, 3);
|
||||||
private TripletEntier t2 = new TripletEntier(4, 4, 2);
|
private TripletEntier t2 = new TripletEntier(4, 4, 2);
|
||||||
private TripletEntier t3 = new TripletEntier(4, 5, 1);
|
private TripletEntier t3 = new TripletEntier(4, 5, 1);
|
||||||
private TripletEntier t4 = new TripletEntier(3, 5, 2);
|
private TripletEntier t4 = new TripletEntier(3, 5, 2);
|
||||||
private TripletEntier t5 = new TripletEntier(1, 2, 3);
|
private TripletEntier t5 = new TripletEntier(1, 2, 3);
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void avantTest() {
|
public void avantTest() {
|
||||||
System.out.println("----------Debut Test-------------");
|
System.out.println("----------Debut Test-------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void apresTest() {
|
public void apresTest() {
|
||||||
System.out.println("-----------Fin Test-------------");
|
System.out.println("-----------Fin Test-------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSomme() {
|
void testSomme() {
|
||||||
|
|
||||||
assertEquals(10, t1.somme());
|
assertEquals(10, t1.somme());
|
||||||
assertEquals(10, t2.somme());
|
assertEquals(10, t2.somme());
|
||||||
assertEquals(10, t3.somme());
|
assertEquals(10, t3.somme());
|
||||||
assertEquals(10, t4.somme());
|
assertEquals(10, t4.somme());
|
||||||
assertEquals(6, t5.somme());
|
assertEquals(6, t5.somme());
|
||||||
|
|
||||||
System.out.println("Test Somme Passe correctement !");
|
System.out.println("Test Somme Passe correctement !");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testMoyenne() {
|
void testMoyenne() {
|
||||||
assertEquals(2., t5.moyenne(), 0.00000001);
|
assertEquals(2., t5.moyenne(), 0.00000001);
|
||||||
assertEquals(3.33333333, t4.moyenne(), 0.00000001);
|
assertEquals(3.33333333, t4.moyenne(), 0.00000001);
|
||||||
assertEquals(3.33333333, t3.moyenne(), 0.00000001);
|
assertEquals(3.33333333, t3.moyenne(), 0.00000001);
|
||||||
assertEquals(3.33333333, t2.moyenne(), 0.00000001);
|
assertEquals(3.33333333, t2.moyenne(), 0.00000001);
|
||||||
assertEquals(3.33333333, t1.moyenne(), 0.00000001);
|
assertEquals(3.33333333, t1.moyenne(), 0.00000001);
|
||||||
|
|
||||||
System.out.println("Test des sommes Passe correctement !");
|
System.out.println("Test des sommes Passe correctement !");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testConcatenantion() {
|
void testConcatenantion() {
|
||||||
assertEquals("433", t1.concatenation());
|
assertEquals("433", t1.concatenation());
|
||||||
assertEquals("442", t2.concatenation());
|
assertEquals("442", t2.concatenation());
|
||||||
assertEquals("451", t3.concatenation());
|
assertEquals("451", t3.concatenation());
|
||||||
assertEquals("352", t4.concatenation());
|
assertEquals("352", t4.concatenation());
|
||||||
assertEquals("123", t5.concatenation());
|
assertEquals("123", t5.concatenation());
|
||||||
|
|
||||||
System.out.println("Test des concatenations Passe correctement !");
|
System.out.println("Test des concatenations Passe correctement !");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testToSting() {
|
void testToSting() {
|
||||||
assertEquals("[a=4, b=3, c=3]", t1.toString());
|
assertEquals("[a=4, b=3, c=3]", t1.toString());
|
||||||
assertEquals("[a=4, b=4, c=2]", t2.toString());
|
assertEquals("[a=4, b=4, c=2]", t2.toString());
|
||||||
assertEquals("[a=4, b=5, c=1]", t3.toString());
|
assertEquals("[a=4, b=5, c=1]", t3.toString());
|
||||||
assertEquals("[a=3, b=5, c=2]", t4.toString());
|
assertEquals("[a=3, b=5, c=2]", t4.toString());
|
||||||
assertEquals("[a=1, b=2, c=3]", t5.toString());
|
assertEquals("[a=1, b=2, c=3]", t5.toString());
|
||||||
|
|
||||||
System.out.println("Test du toString Passe correctement !");
|
System.out.println("Test du toString Passe correctement !");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testEquals() {
|
void testEquals() {
|
||||||
assertEquals(true, t1.equals(t1));
|
assertEquals(true, t1.equals(t1));
|
||||||
assertEquals(true, t2.equals(t2));
|
assertEquals(true, t2.equals(t2));
|
||||||
assertEquals(true, t3.equals(t3));
|
assertEquals(true, t3.equals(t3));
|
||||||
assertEquals(true, t4.equals(t4));
|
assertEquals(true, t4.equals(t4));
|
||||||
assertEquals(true, t5.equals(t5));
|
assertEquals(true, t5.equals(t5));
|
||||||
|
|
||||||
assertEquals(false, t1.equals(t2));
|
assertEquals(false, t1.equals(t2));
|
||||||
assertEquals(false, t2.equals(t3));
|
assertEquals(false, t2.equals(t3));
|
||||||
assertEquals(false, t3.equals(t1));
|
assertEquals(false, t3.equals(t1));
|
||||||
assertEquals(false, t4.equals(t5));
|
assertEquals(false, t4.equals(t5));
|
||||||
assertEquals(false, t5.equals(t1));
|
assertEquals(false, t5.equals(t1));
|
||||||
|
|
||||||
System.out.println("Test des equals Passe correctement !");
|
System.out.println("Test des equals Passe correctement !");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
84
TD2/src/tripletEntier/TestTripletEntier.java → src/TD2/tripletEntier/TestTripletEntier.java
Executable file → Normal file
84
TD2/src/tripletEntier/TestTripletEntier.java → src/TD2/tripletEntier/TestTripletEntier.java
Executable file → Normal file
@ -1,41 +1,43 @@
|
|||||||
package tripletEntier;
|
package tripletEntier;
|
||||||
|
|
||||||
public class TestTripletEntier
|
public class TestTripletEntier
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
TripletEntier t1 = new TripletEntier(2, 2, 3);
|
TripletEntier t1 = new TripletEntier(2, 2, 3);
|
||||||
|
|
||||||
System.out.println("Somme "+t1+" = "+t1.somme());
|
System.out.println("Somme "+t1+" = "+t1.somme());
|
||||||
System.out.println(t1.somme() == 7);
|
System.out.println(t1.somme() == 7);
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
|
|
||||||
TripletEntier t2 = new TripletEntier(1, 2, 3);
|
TripletEntier t2 = new TripletEntier(1, 2, 3);
|
||||||
|
|
||||||
System.out.println(t2);
|
System.out.println(t2);
|
||||||
/*String resConcat = t2.concatenation();
|
String resConcat = t2.concatenation();
|
||||||
|
|
||||||
/*System.out.println(resConcat);
|
System.out.println(resConcat);
|
||||||
System.out.println(resConcat == "123");
|
System.out.println(resConcat == "123");
|
||||||
System.out.println(resConcat.equals("123"));
|
System.out.println(resConcat.equals("123"));
|
||||||
System.out.println("Moyenne "+t2+" = "+t2.moyenne());
|
System.out.println("Moyenne "+t2+" = "+t2.moyenne());
|
||||||
System.out.println();*/
|
System.out.println();
|
||||||
|
|
||||||
System.out.println(new TripletEntier(1, 2, 4).moyenne());
|
System.out.println(new TripletEntier(1, 2, 4).moyenne());
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
TripletEntier t3 = new TripletEntier(1, 2, 2);
|
TripletEntier t3 = new TripletEntier(1, 2, 2);
|
||||||
System.out.println("Moyenne "+t3+" = "+t3.moyenne());
|
System.out.println("Moyenne "+t3+" = "+t3.moyenne());
|
||||||
System.out.println(t3.moyenne() == (5.0/3.0));
|
System.out.println(t3.moyenne() == (5.0/3.0));
|
||||||
System.out.println(t3.moyenne() == 1.666667);
|
System.out.println(t3.moyenne() == 1.666667);
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
/*t1.ajoutElement(5, 2);
|
/*
|
||||||
System.out.println(t1);
|
t1.ajoutElement(5, 2);
|
||||||
t1.ajoutElement(5, 5);
|
System.out.println(t1);
|
||||||
t1.ajout1erElement(10);
|
t1.ajoutElement(5, 5);
|
||||||
System.out.println(t1);*/
|
t1.ajout1erElement(10);
|
||||||
}
|
System.out.println(t1);
|
||||||
}
|
*/
|
||||||
|
}
|
||||||
|
}
|
52
src/TD2/tripletEntier/TripletEntier.java
Normal file
52
src/TD2/tripletEntier/TripletEntier.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package tripletEntier;
|
||||||
|
|
||||||
|
public class TripletEntier {
|
||||||
|
|
||||||
|
private int unA;
|
||||||
|
private int unB;
|
||||||
|
private int unC;
|
||||||
|
|
||||||
|
public TripletEntier(int a, int b, int c) {
|
||||||
|
this.unA = a;
|
||||||
|
this.unB = b;
|
||||||
|
this.unC = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TripletEntier() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public int somme() {
|
||||||
|
return this.unA + this.unB + this.unC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float moyenne() {
|
||||||
|
return (float)this.somme()/3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String concatenation() {
|
||||||
|
return "" + this.unA + this.unB + this.unC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ajoutElement(int e) {
|
||||||
|
this.unA = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contient(int e) {
|
||||||
|
return (this.unA == e) || (this.unB == e) || (this.unC == e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(TripletEntier t) {
|
||||||
|
return (this.unA == t.unA) && (this.unB == t.unB) && (this.unC == t.unC);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TripletEntier clone(TripletEntier t) {
|
||||||
|
return new TripletEntier(t.unA, t.unB, t.unC);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[" + this.unA + "," + this.unB + "," + this.unC +"]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
132
TD3 src/boite/Boite.java → src/TD3/boite/Boite.java
Executable file → Normal file
132
TD3 src/boite/Boite.java → src/TD3/boite/Boite.java
Executable file → Normal file
@ -1,66 +1,66 @@
|
|||||||
package boite;
|
package boite;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
public class Boite {
|
public class Boite {
|
||||||
final private int BOITEMAX = 5;
|
final private int BOITEMAX = 5;
|
||||||
private Color couleur;
|
private Color couleur;
|
||||||
private Objet contenu;
|
private Objet contenu;
|
||||||
private Boite[] bContent = new Boite[15];
|
private Boite[] bContent = new Boite[15];
|
||||||
private int nbB = 0;
|
private int nbB = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Boite(Color col) {
|
public Boite(Color col) {
|
||||||
couleur = col;
|
couleur = col;
|
||||||
contenu = null;
|
contenu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boite(Color col, Objet obj) {
|
public Boite(Color col, Objet obj) {
|
||||||
couleur = col;
|
couleur = col;
|
||||||
contenu = obj;
|
contenu = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boite(Color col, Boite box) {
|
public Boite(Color col, Boite box) {
|
||||||
couleur = col;
|
couleur = col;
|
||||||
bContent[nbB] = box;
|
bContent[nbB] = box;
|
||||||
nbB += 1;
|
nbB += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boite(Color col, Boite box, Objet obj) {
|
public Boite(Color col, Boite box, Objet obj) {
|
||||||
couleur = col;
|
couleur = col;
|
||||||
contenu = obj;
|
contenu = obj;
|
||||||
bContent[nbB] = box;
|
bContent[nbB] = box;
|
||||||
nbB += 1;
|
nbB += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
return couleur;
|
return couleur;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Objet getObjet() {
|
public Objet getObjet() {
|
||||||
return contenu;
|
return contenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contientObjet(Objet obj) {
|
public boolean contientObjet(Objet obj) {
|
||||||
return obj == contenu;
|
return obj == contenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean estVide() {
|
public boolean estVide() {
|
||||||
return contenu ==null && nbB == 0;
|
return contenu ==null && nbB == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ajouteBoite(Boite B) {
|
public void ajouteBoite(Boite B) {
|
||||||
if (nbB+1 >= 5)
|
if (nbB+1 >= 5)
|
||||||
throw new RuntimeException("Maximum déjà atteint");
|
throw new RuntimeException("Maximum déjà atteint");
|
||||||
bContent[nbB] = B;
|
bContent[nbB] = B;
|
||||||
nbB += 1;
|
nbB += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
76
TD3 src/boite/Objet.java → src/TD3/boite/Objet.java
Executable file → Normal file
76
TD3 src/boite/Objet.java → src/TD3/boite/Objet.java
Executable file → Normal file
@ -1,38 +1,38 @@
|
|||||||
package boite;
|
package boite;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class Objet {
|
public class Objet {
|
||||||
Color couleur;
|
Color couleur;
|
||||||
|
|
||||||
public Objet() {
|
public Objet() {
|
||||||
couleur = Color.white;
|
couleur = Color.white;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Objet(Color c) {
|
public Objet(Color c) {
|
||||||
couleur = c;
|
couleur = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeCouleur(Color c) {
|
public void changeCouleur(Color c) {
|
||||||
if (!couleur.equals(c))
|
if (!couleur.equals(c))
|
||||||
couleur = c;
|
couleur = c;
|
||||||
else
|
else
|
||||||
System.out.println("L'objet est déjà de couleur "+c);
|
System.out.println("L'objet est déjà de couleur "+c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeCouleur2(Color c) {
|
public void changeCouleur2(Color c) {
|
||||||
if (couleur.equals(c))
|
if (couleur.equals(c))
|
||||||
throw new RuntimeException("Même couleur");
|
throw new RuntimeException("Même couleur");
|
||||||
couleur = c;
|
couleur = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
Objet currentO = (Objet) o;
|
Objet currentO = (Objet) o;
|
||||||
return (currentO.couleur.equals(couleur));
|
return (currentO.couleur.equals(couleur));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Objet "+couleur;
|
return "Objet "+couleur;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
46
TD3 src/boite/testBoite.java → src/TD3/boite/testBoite.java
Executable file → Normal file
46
TD3 src/boite/testBoite.java → src/TD3/boite/testBoite.java
Executable file → Normal file
@ -1,23 +1,23 @@
|
|||||||
package boite;
|
package boite;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
public class testBoite {
|
public class testBoite {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Boite b1 = new Boite(Color.green);
|
Boite b1 = new Boite(Color.green);
|
||||||
Boite b2 = new Boite(Color.green, new Objet(Color.red));
|
Boite b2 = new Boite(Color.green, new Objet(Color.red));
|
||||||
Boite b3 = new Boite(Color.green, new Boite(Color.blue));
|
Boite b3 = new Boite(Color.green, new Boite(Color.blue));
|
||||||
Boite b4 = new Boite(Color.green, new Boite(Color.blue));
|
Boite b4 = new Boite(Color.green, new Boite(Color.blue));
|
||||||
b4.ajouteBoite(new Boite(Color.yellow));
|
b4.ajouteBoite(new Boite(Color.yellow));
|
||||||
Boite b5 = new Boite(Color.green, new Objet(Color.red));
|
Boite b5 = new Boite(Color.green, new Objet(Color.red));
|
||||||
b5.ajouteBoite(new Boite(Color.blue));
|
b5.ajouteBoite(new Boite(Color.blue));
|
||||||
try {
|
try {
|
||||||
b2.getObjet().changeCouleur2(Color.red);
|
b2.getObjet().changeCouleur2(Color.red);
|
||||||
} catch(RuntimeException e) {
|
} catch(RuntimeException e) {
|
||||||
e.getMessage();
|
e.getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
0
TD3 src/fleuriste/Bouquet.java → src/TD3/fleuriste/Bouquet.java
Executable file → Normal file
0
TD3 src/fleuriste/Bouquet.java → src/TD3/fleuriste/Bouquet.java
Executable file → Normal file
0
TD3 src/fleuriste/Fleur.java → src/TD3/fleuriste/Fleur.java
Executable file → Normal file
0
TD3 src/fleuriste/Fleur.java → src/TD3/fleuriste/Fleur.java
Executable file → Normal file
80
TD3/src/fleuriste/LotFleur.java → src/TD3/fleuriste/LotFleur.java
Executable file → Normal file
80
TD3/src/fleuriste/LotFleur.java → src/TD3/fleuriste/LotFleur.java
Executable file → Normal file
@ -1,40 +1,40 @@
|
|||||||
package fleuriste;
|
package fleuriste;
|
||||||
|
|
||||||
public class LotFleur {
|
public class LotFleur {
|
||||||
|
|
||||||
private int quantite;
|
private int quantite;
|
||||||
private Fleur Fleur;
|
private Fleur Fleur;
|
||||||
|
|
||||||
//getters
|
//getters
|
||||||
public int getQuantite() {
|
public int getQuantite() {
|
||||||
return quantite;
|
return quantite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fleur getFleur() {
|
public Fleur getFleur() {
|
||||||
return Fleur;
|
return Fleur;
|
||||||
}
|
}
|
||||||
|
|
||||||
//setters
|
//setters
|
||||||
public void setQuantite(int quantite) {
|
public void setQuantite(int quantite) {
|
||||||
this.quantite = quantite;
|
this.quantite = quantite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFleur(Fleur fleur) {
|
public void setFleur(Fleur fleur) {
|
||||||
Fleur = fleur;
|
Fleur = fleur;
|
||||||
}
|
}
|
||||||
|
|
||||||
//instructions
|
//instructions
|
||||||
public LotFleur(Fleur nomFleur, int quantiteFleur) {
|
public LotFleur(Fleur nomFleur, int quantiteFleur) {
|
||||||
this.quantite = quantiteFleur;
|
this.quantite = quantiteFleur;
|
||||||
this.setFleur(nomFleur);
|
this.setFleur(nomFleur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
0
TD3 src/fleuriste/LotFleurs.java → src/TD3/fleuriste/LotFleurs.java
Executable file → Normal file
0
TD3 src/fleuriste/LotFleurs.java → src/TD3/fleuriste/LotFleurs.java
Executable file → Normal file
0
TD3 src/fleuriste/Stock.java → src/TD3/fleuriste/Stock.java
Executable file → Normal file
0
TD3 src/fleuriste/Stock.java → src/TD3/fleuriste/Stock.java
Executable file → Normal file
54
TD3 src/fleuriste/TestBouquet.java → src/TD3/fleuriste/TestBouquet.java
Executable file → Normal file
54
TD3 src/fleuriste/TestBouquet.java → src/TD3/fleuriste/TestBouquet.java
Executable file → Normal file
@ -1,27 +1,27 @@
|
|||||||
package fleuriste;
|
package fleuriste;
|
||||||
|
|
||||||
public class TestBouquet {
|
public class TestBouquet {
|
||||||
public static void main( String[] args) {
|
public static void main( String[] args) {
|
||||||
Fleur rose = new Fleur("rose",2.6);
|
Fleur rose = new Fleur("rose",2.6);
|
||||||
Fleur tulipe = new Fleur("tulipe",0.4);
|
Fleur tulipe = new Fleur("tulipe",0.4);
|
||||||
Fleur oeillet = new Fleur("oeillet",1.8);
|
Fleur oeillet = new Fleur("oeillet",1.8);
|
||||||
|
|
||||||
LotFleurs lotroses = new LotFleurs(rose,5);
|
LotFleurs lotroses = new LotFleurs(rose,5);
|
||||||
LotFleurs lottulipes = new LotFleurs(tulipe,7);
|
LotFleurs lottulipes = new LotFleurs(tulipe,7);
|
||||||
LotFleurs lotoeillets = new LotFleurs(oeillet,3);
|
LotFleurs lotoeillets = new LotFleurs(oeillet,3);
|
||||||
|
|
||||||
Bouquet b = new Bouquet(lotroses, lottulipes, lotoeillets);
|
Bouquet b = new Bouquet(lotroses, lottulipes, lotoeillets);
|
||||||
double prixb = b.prix(); //calcule le prix d<EFBFBD>un bouquet
|
double prixb = b.prix(); //calcule le prix d<EFBFBD>un bouquet
|
||||||
System.out.println(b+" : "+prixb+" euros");
|
System.out.println(b+" : "+prixb+" euros");
|
||||||
|
|
||||||
Stock magasin = new Stock(rose,tulipe,oeillet);
|
Stock magasin = new Stock(rose,tulipe,oeillet);
|
||||||
System.out.println(magasin);
|
System.out.println(magasin);
|
||||||
magasin.ajouteRose(100);
|
magasin.ajouteRose(100);
|
||||||
magasin.ajouteTulipe(150);
|
magasin.ajouteTulipe(150);
|
||||||
magasin.ajouteOeillet(200);
|
magasin.ajouteOeillet(200);
|
||||||
System.out.println(magasin);
|
System.out.println(magasin);
|
||||||
// Est-ce que le stock permet de produire le bouquet b ?
|
// Est-ce que le stock permet de produire le bouquet b ?
|
||||||
boolean orderBouquet = magasin.bouquetFaisable(b);
|
boolean orderBouquet = magasin.bouquetFaisable(b);
|
||||||
System.out.println(orderBouquet);
|
System.out.println(orderBouquet);
|
||||||
}
|
}
|
||||||
}
|
}
|
98
TD3/src/segment/Segment.java → src/TD3/segment/Segment.java
Executable file → Normal file
98
TD3/src/segment/Segment.java → src/TD3/segment/Segment.java
Executable file → Normal file
@ -1,49 +1,49 @@
|
|||||||
package segment;
|
package segment;
|
||||||
import point.Point;
|
import point.Point;
|
||||||
|
|
||||||
public class Segment {
|
public class Segment {
|
||||||
|
|
||||||
public Point origine;
|
public Point origine;
|
||||||
public Point extremite;
|
public Point extremite;
|
||||||
|
|
||||||
public Segment(Point p1, Point p2) throws Throwable
|
public Segment(Point p1, Point p2) throws Throwable
|
||||||
{
|
{
|
||||||
if(p1.equals(p2)) throw new Throwable("Les points sont confondus !");
|
if(p1.equals(p2)) throw new Throwable("Les points sont confondus !");
|
||||||
this.origine = p1;
|
this.origine = p1;
|
||||||
this.extremite = p2;
|
this.extremite = p2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object B)
|
public boolean equals(Object B)
|
||||||
{
|
{
|
||||||
Segment s = (Segment) 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));
|
return this.origine.equals(s.origine)&&(this.extremite.equals(s.extremite)) || this.origine.equals(extremite)&&(this.extremite.equals(s.origine));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "[" + origine + " - " + extremite + "]";
|
return "[" + origine + " - " + extremite + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public Object clone() throws Throwable
|
/*public Object clone() throws Throwable
|
||||||
{
|
{
|
||||||
return new Segment((Point)this.origine.clone, (Point)this.extremite.clone);
|
return new Segment((Point)this.origine.clone, (Point)this.extremite.clone);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public double longueur()
|
public double longueur()
|
||||||
{
|
{
|
||||||
return origine.getDistance(extremite);
|
return origine.getDistance(extremite);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Segment projX() throws Throwable
|
public Segment projX() throws Throwable
|
||||||
{
|
{
|
||||||
if(origine.projX().equals(extremite.projX())) throw new Throwable("Les points projetes sont confondus !");
|
if(origine.projX().equals(extremite.projX())) throw new Throwable("Les points projetes sont confondus !");
|
||||||
return new Segment(origine.projX(), extremite.projX());
|
return new Segment(origine.projX(), extremite.projX());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Segment projY() throws Throwable
|
public Segment projY() throws Throwable
|
||||||
{
|
{
|
||||||
if(origine.projY().equals(extremite.projY())) throw new Throwable("Les points projetes sont confondus !");
|
if(origine.projY().equals(extremite.projY())) throw new Throwable("Les points projetes sont confondus !");
|
||||||
return new Segment(origine.projY(), extremite.projY());
|
return new Segment(origine.projY(), extremite.projY());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
86
TD3/src/segment/TestSegment.java → src/TD3/segment/TestSegment.java
Executable file → Normal file
86
TD3/src/segment/TestSegment.java → src/TD3/segment/TestSegment.java
Executable file → Normal file
@ -1,43 +1,43 @@
|
|||||||
package segment;
|
package segment;
|
||||||
import point.Point;
|
import point.Point;
|
||||||
|
|
||||||
public class TestSegment {
|
public class TestSegment {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Point O = new Point();
|
Point O = new Point();
|
||||||
Point I = new Point(1.0, 0.0);
|
Point I = new Point(1.0, 0.0);
|
||||||
Point J = new Point(0.0, 1.0);
|
Point J = new Point(0.0, 1.0);
|
||||||
Point A = new Point(1.0, 3.5);
|
Point A = new Point(1.0, 3.5);
|
||||||
Point B = new Point(8.0, 20.0);
|
Point B = new Point(8.0, 20.0);
|
||||||
Point C = new Point(-2.0, 3.0);
|
Point C = new Point(-2.0, 3.0);
|
||||||
Point D = new Point(1.0, 1.0);
|
Point D = new Point(1.0, 1.0);
|
||||||
|
|
||||||
Segment AB = null;
|
Segment AB = null;
|
||||||
Segment BC = null;
|
Segment BC = null;
|
||||||
Segment OI = null;
|
Segment OI = null;
|
||||||
Segment OJ = null;
|
Segment OJ = null;
|
||||||
Segment OD = null;
|
Segment OD = null;
|
||||||
//Segment AA = null;
|
//Segment AA = null;
|
||||||
try {
|
try {
|
||||||
AB = new Segment(A, B);
|
AB = new Segment(A, B);
|
||||||
BC = new Segment(B, C);
|
BC = new Segment(B, C);
|
||||||
OI = new Segment(O, I);
|
OI = new Segment(O, I);
|
||||||
OJ = new Segment(O, J);
|
OJ = new Segment(O, J);
|
||||||
OD = new Segment(O, D);
|
OD = new Segment(O, D);
|
||||||
//AA = new Segment(A, A);
|
//AA = new Segment(A, A);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
System.out.println("Erreur : " + t);
|
System.out.println("Erreur : " + t);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(OI.toString());
|
System.out.println(OI.toString());
|
||||||
System.out.println(OJ.toString());
|
System.out.println(OJ.toString());
|
||||||
System.out.println(AB.toString());
|
System.out.println(AB.toString());
|
||||||
System.out.println(BC.toString());
|
System.out.println(BC.toString());
|
||||||
System.out.println(OD.toString());
|
System.out.println(OD.toString());
|
||||||
//System.out.println(AA.toString());
|
//System.out.println(AA.toString());
|
||||||
|
|
||||||
System.out.println("Hello world !");
|
System.out.println("Hello world !");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
0
TD3 src/segments/Segment.java → src/TD3/segments/Segment.java
Executable file → Normal file
0
TD3 src/segments/Segment.java → src/TD3/segments/Segment.java
Executable file → Normal file
0
TD3 src/segments/TestSegment.java → src/TD3/segments/TestSegment.java
Executable file → Normal file
0
TD3 src/segments/TestSegment.java → src/TD3/segments/TestSegment.java
Executable file → Normal file
156
TD4/src/pointcolore/PointColore.java → src/TD4/pointcolore/PointColore.java
Executable file → Normal file
156
TD4/src/pointcolore/PointColore.java → src/TD4/pointcolore/PointColore.java
Executable file → Normal file
@ -1,78 +1,78 @@
|
|||||||
package pointcolore;
|
package pointcolore;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import point.Point;
|
import point.Point;
|
||||||
|
|
||||||
public class PointColore extends Point {
|
public class PointColore extends Point {
|
||||||
|
|
||||||
private Color couleur;
|
private Color couleur;
|
||||||
|
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|
||||||
public Color getCouleur() {
|
public Color getCouleur() {
|
||||||
return couleur;
|
return couleur;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCouleur(Color couleur) {
|
public void setCouleur(Color couleur) {
|
||||||
this.couleur = couleur;
|
this.couleur = couleur;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Couleur = " + couleur + " --- Coords = " + super.toString();
|
return "Couleur = " + couleur + " --- Coords = " + super.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|
||||||
public PointColore() {
|
public PointColore() {
|
||||||
this.setCouleur(Color.black);
|
this.setCouleur(Color.black);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointColore(double x, double y, Color c) {
|
public PointColore(double x, double y, Color c) {
|
||||||
super(x,y);
|
super(x,y);
|
||||||
this.setCouleur(c);
|
this.setCouleur(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void colore(Color c){
|
public void colore(Color c){
|
||||||
this.setCouleur(c);
|
this.setCouleur(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean likeColor(PointColore pc) {
|
public boolean likeColor(PointColore pc) {
|
||||||
|
|
||||||
if(this.couleur == pc.couleur)
|
if(this.couleur == pc.couleur)
|
||||||
return true;
|
return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals (Object obj)
|
public boolean equals (Object obj)
|
||||||
{
|
{
|
||||||
Point p = (Point)obj;
|
Point p = (Point)obj;
|
||||||
if (super.x == p.x && super.y == p.y)
|
if (super.x == p.x && super.y == p.y)
|
||||||
return true;
|
return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointColore projX()
|
public PointColore projX()
|
||||||
{
|
{
|
||||||
Point p = super.projX();
|
Point p = super.projX();
|
||||||
return new PointColore(p.getX(), p.getY(), this.couleur);
|
return new PointColore(p.getX(), p.getY(), this.couleur);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointColore projY()
|
public PointColore projY()
|
||||||
{
|
{
|
||||||
Point p = super.projY();
|
Point p = super.projY();
|
||||||
return new PointColore(p.getY(), p.getY(), this.couleur);
|
return new PointColore(p.getY(), p.getY(), this.couleur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
60
TD4/src/pointcolore/TestPointColore.java → src/TD4/pointcolore/TestPointColore.java
Executable file → Normal file
60
TD4/src/pointcolore/TestPointColore.java → src/TD4/pointcolore/TestPointColore.java
Executable file → Normal file
@ -1,30 +1,30 @@
|
|||||||
package pointcolore;
|
package pointcolore;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import point.Point;
|
import point.Point;
|
||||||
|
|
||||||
public class TestPointColore {
|
public class TestPointColore {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Point Z = new Point(1., 8.);
|
Point Z = new Point(1., 8.);
|
||||||
PointColore A = new PointColore(3., 5., Color.black);
|
PointColore A = new PointColore(3., 5., Color.black);
|
||||||
PointColore B = new PointColore(2.5, 8., Color.green);
|
PointColore B = new PointColore(2.5, 8., Color.green);
|
||||||
PointColore C = new PointColore(1., -2., Color.red);
|
PointColore C = new PointColore(1., -2., Color.red);
|
||||||
PointColore O = new PointColore(0., 0., Color.yellow);
|
PointColore O = new PointColore(0., 0., Color.yellow);
|
||||||
PointColore I = new PointColore(1.0, 0.0, Color.yellow);
|
PointColore I = new PointColore(1.0, 0.0, Color.yellow);
|
||||||
PointColore J = new PointColore(0.0, 1.0, Color.red);
|
PointColore J = new PointColore(0.0, 1.0, Color.red);
|
||||||
|
|
||||||
System.out.println(" Z = " + Z.toString());
|
System.out.println(" Z = " + Z.toString());
|
||||||
System.out.println(" O = " + O.toString());
|
System.out.println(" O = " + O.toString());
|
||||||
System.out.println(" I = " + I.toString());
|
System.out.println(" I = " + I.toString());
|
||||||
System.out.println(" J = " + J.toString());
|
System.out.println(" J = " + J.toString());
|
||||||
System.out.println(" A = " + A.toString());
|
System.out.println(" A = " + A.toString());
|
||||||
System.out.println(" B = " + B.toString());
|
System.out.println(" B = " + B.toString());
|
||||||
System.out.println(" C = " + C.toString());
|
System.out.println(" C = " + C.toString());
|
||||||
|
|
||||||
A.setCouleur(Color.white);
|
A.setCouleur(Color.white);
|
||||||
System.out.println(A.toString());
|
System.out.println(A.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
74
TD6/src/vehicule/Avion.java → src/TD4/vehicule/Avion.java
Executable file → Normal file
74
TD6/src/vehicule/Avion.java → src/TD4/vehicule/Avion.java
Executable file → Normal file
@ -1,37 +1,37 @@
|
|||||||
package vehicule;
|
package vehicule;
|
||||||
|
|
||||||
public class Avion extends Vehicule {
|
public class Avion extends Vehicule {
|
||||||
protected String moteur;
|
protected String moteur;
|
||||||
protected int heuresVol;
|
protected int heuresVol;
|
||||||
|
|
||||||
public Avion() {
|
public Avion() {
|
||||||
moteur = "Moteur";
|
moteur = "Moteur";
|
||||||
heuresVol = 0;
|
heuresVol = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Avion(String marque, int date, double prixac, String moteur, int heures) {
|
public Avion(String marque, int date, double prixac, String moteur, int heures) {
|
||||||
this.moteur = moteur;
|
this.moteur = moteur;
|
||||||
heuresVol = heures;
|
heuresVol = heures;
|
||||||
this.marque = marque;
|
this.marque = marque;
|
||||||
dateAchat = date;
|
dateAchat = date;
|
||||||
prixAchat = prixac;
|
prixAchat = prixac;
|
||||||
prixCourant = 0;
|
prixCourant = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculePrix(int annee) {
|
public void calculePrix(int annee) {
|
||||||
double pourcentage;
|
double pourcentage;
|
||||||
if (moteur == "hélice") {
|
if (moteur == "hélice") {
|
||||||
pourcentage = 10*Math.floor(this.heuresVol/100);
|
pourcentage = 10*Math.floor(this.heuresVol/100);
|
||||||
} else {
|
} else {
|
||||||
pourcentage = 10* Math.floor(this.heuresVol/1000);
|
pourcentage = 10* Math.floor(this.heuresVol/1000);
|
||||||
}
|
}
|
||||||
super.prixCourant = super.prixAchat - ((super.prixAchat/100) * pourcentage);
|
super.prixCourant = super.prixAchat - ((super.prixAchat/100) * pourcentage);
|
||||||
if (super.prixCourant < 0) {
|
if (super.prixCourant < 0) {
|
||||||
super.prixCourant = 0;
|
super.prixCourant = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void affiche() {
|
public void affiche() {
|
||||||
System.out.println(""+this.marque+" "+this.dateAchat+" "+this.prixAchat+" "+prixCourant+" "+this.moteur+" "+this.heuresVol);
|
System.out.println(""+this.marque+" "+this.dateAchat+" "+this.prixAchat+" "+prixCourant+" "+this.moteur+" "+this.heuresVol);
|
||||||
}
|
}
|
||||||
}
|
}
|
56
TD6/src/vehicule/GestionVehicule.java → src/TD4/vehicule/GestionVehicule.java
Executable file → Normal file
56
TD6/src/vehicule/GestionVehicule.java → src/TD4/vehicule/GestionVehicule.java
Executable file → Normal file
@ -1,29 +1,29 @@
|
|||||||
package vehicule;
|
package 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);
|
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];
|
Voiture[] garage = new Voiture[3];
|
||||||
Avion[] hangar = new Avion[2];
|
Avion[] hangar = new Avion[2];
|
||||||
|
|
||||||
garage[0] = new Voiture("Peugeot", 2005, 13400.00, 1.4, 5, 4.0, 12000);
|
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[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);
|
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[0] = new Avion("Cessna", 1979, 204739.90, "HELICES", 250);
|
||||||
hangar[1] = new Avion("Gulfstream", 1993, 4321098.00, "REACTION", 1300);
|
hangar[1] = new Avion("Gulfstream", 1993, 4321098.00, "REACTION", 1300);
|
||||||
|
|
||||||
for (int i = 0; i < garage.length; i++) {
|
for (int i = 0; i < garage.length; i++) {
|
||||||
garage[i].calculePrix(ANNEE_ACTUELLE);
|
garage[i].calculePrix(ANNEE_ACTUELLE);
|
||||||
garage[i].affiche();
|
garage[i].affiche();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < hangar.length; i++) {
|
for (int i = 0; i < hangar.length; i++) {
|
||||||
hangar[i].calculePrix(ANNEE_ACTUELLE);
|
hangar[i].calculePrix(ANNEE_ACTUELLE);
|
||||||
hangar[i].affiche();
|
hangar[i].affiche();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
64
TD4/src/vehicule/Vehicule.java → src/TD4/vehicule/Vehicule.java
Executable file → Normal file
64
TD4/src/vehicule/Vehicule.java → src/TD4/vehicule/Vehicule.java
Executable file → Normal file
@ -1,32 +1,32 @@
|
|||||||
package vehicule;
|
package vehicule;
|
||||||
|
|
||||||
public class Vehicule {
|
public class Vehicule {
|
||||||
protected String marque;
|
protected String marque;
|
||||||
protected int dateAchat;
|
protected int dateAchat;
|
||||||
protected double prixAchat;
|
protected double prixAchat;
|
||||||
protected double prixCourant;
|
protected double prixCourant;
|
||||||
|
|
||||||
public Vehicule() {
|
public Vehicule() {
|
||||||
marque = "";
|
marque = "";
|
||||||
dateAchat = 0;
|
dateAchat = 0;
|
||||||
prixAchat = 0;
|
prixAchat = 0;
|
||||||
prixCourant = 0;
|
prixCourant = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vehicule(String s, int d, double pA) {
|
public Vehicule(String s, int d, double pA) {
|
||||||
this.marque = s;
|
this.marque = s;
|
||||||
dateAchat = d;
|
dateAchat = d;
|
||||||
prixAchat = pA;
|
prixAchat = pA;
|
||||||
prixCourant = 0;
|
prixCourant = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculPrix(int y) {
|
public void calculPrix(int y) {
|
||||||
int previousY = this.dateAchat - y;
|
int previousY = this.dateAchat - y;
|
||||||
this.prixCourant = this.prixAchat - ((this.prixAchat/100) * previousY);
|
this.prixCourant = this.prixAchat - ((this.prixAchat/100) * previousY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void affiche() {
|
public void affiche() {
|
||||||
System.out.println(""+this.marque+" "+this.dateAchat+" "+this.prixAchat+" "+prixCourant);
|
System.out.println(""+this.marque+" "+this.dateAchat+" "+this.prixAchat+" "+prixCourant);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
116
TD6/src/vehicule/Voiture.java → src/TD4/vehicule/Voiture.java
Executable file → Normal file
116
TD6/src/vehicule/Voiture.java → src/TD4/vehicule/Voiture.java
Executable file → Normal file
@ -1,58 +1,58 @@
|
|||||||
package vehicule;
|
package vehicule;
|
||||||
|
|
||||||
public class Voiture extends Vehicule {
|
public class Voiture extends Vehicule {
|
||||||
protected double cylindree;
|
protected double cylindree;
|
||||||
protected int nbPorte;
|
protected int nbPorte;
|
||||||
protected double puissance;
|
protected double puissance;
|
||||||
protected double kilometrage;
|
protected double kilometrage;
|
||||||
|
|
||||||
public Voiture() {
|
public Voiture() {
|
||||||
cylindree = 0;
|
cylindree = 0;
|
||||||
nbPorte = 0;
|
nbPorte = 0;
|
||||||
puissance = 0;
|
puissance = 0;
|
||||||
kilometrage = 0;
|
kilometrage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Voiture(String marque, int date, double prixac, double cyl, int nbP, double pui, double kilo) {
|
public Voiture(String marque, int date, double prixac, double cyl, int nbP, double pui, double kilo) {
|
||||||
cylindree = cyl;
|
cylindree = cyl;
|
||||||
nbPorte = nbP;
|
nbPorte = nbP;
|
||||||
puissance = pui;
|
puissance = pui;
|
||||||
kilometrage = kilo;
|
kilometrage = kilo;
|
||||||
this.marque = marque;
|
this.marque = marque;
|
||||||
dateAchat = date;
|
dateAchat = date;
|
||||||
prixAchat = prixac;
|
prixAchat = prixac;
|
||||||
prixCourant = 0;
|
prixCourant = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void calculePrix(int annee) {
|
public void calculePrix(int annee) {
|
||||||
int anneesPass = (annee - this.dateAchat)*2;
|
int anneesPass = (annee - this.dateAchat)*2;
|
||||||
double pourcentagekm = Math.floor(this.kilometrage/10000);
|
double pourcentagekm = Math.floor(this.kilometrage/10000);
|
||||||
boolean malus = false;
|
boolean malus = false;
|
||||||
boolean bonus = false;
|
boolean bonus = false;
|
||||||
if (this.marque == "fiat" || this.marque == "renaud") {
|
if (this.marque == "fiat" || this.marque == "renaud") {
|
||||||
malus = true;
|
malus = true;
|
||||||
} else if (this.marque == "ferrari" || this.marque == "mclaren") {
|
} else if (this.marque == "ferrari" || this.marque == "mclaren") {
|
||||||
bonus = true;
|
bonus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.prixCourant = this.prixAchat - ((this.prixAchat/100) * anneesPass);
|
this.prixCourant = this.prixAchat - ((this.prixAchat/100) * anneesPass);
|
||||||
this.prixCourant -= ((this.prixAchat/100)*(pourcentagekm*5));
|
this.prixCourant -= ((this.prixAchat/100)*(pourcentagekm*5));
|
||||||
if (malus)
|
if (malus)
|
||||||
this.prixCourant -= (this.prixAchat/100)*10;
|
this.prixCourant -= (this.prixAchat/100)*10;
|
||||||
|
|
||||||
if (bonus)
|
if (bonus)
|
||||||
this.prixCourant += (this.prixAchat/100)*20;
|
this.prixCourant += (this.prixAchat/100)*20;
|
||||||
|
|
||||||
if (this.prixCourant < 0) {
|
if (this.prixCourant < 0) {
|
||||||
this.prixCourant = 0;
|
this.prixCourant = 0;
|
||||||
} else if (this.prixCourant > this.prixAchat) {
|
} else if (this.prixCourant > this.prixAchat) {
|
||||||
this.prixCourant = this.prixAchat;
|
this.prixCourant = this.prixAchat;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void affiche() {
|
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);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
156
TD5/src/pointcolore/PointColore.java → src/TD5/pointcolore/PointColore.java
Executable file → Normal file
156
TD5/src/pointcolore/PointColore.java → src/TD5/pointcolore/PointColore.java
Executable file → Normal file
@ -1,78 +1,78 @@
|
|||||||
package pointcolore;
|
package pointcolore;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import point.Point;
|
import point.Point;
|
||||||
|
|
||||||
public class PointColore extends Point {
|
public class PointColore extends Point {
|
||||||
|
|
||||||
private Color couleur;
|
private Color couleur;
|
||||||
|
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|
||||||
public Color getCouleur() {
|
public Color getCouleur() {
|
||||||
return couleur;
|
return couleur;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCouleur(Color couleur) {
|
public void setCouleur(Color couleur) {
|
||||||
this.couleur = couleur;
|
this.couleur = couleur;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + " - Couleur : " + couleur + ")";
|
return super.toString() + " - Couleur : " + couleur + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|
||||||
public PointColore() {
|
public PointColore() {
|
||||||
this.setCouleur(Color.black);
|
this.setCouleur(Color.black);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointColore(double x, double y, Color c) {
|
public PointColore(double x, double y, Color c) {
|
||||||
super(x,y);
|
super(x,y);
|
||||||
this.setCouleur(c);
|
this.setCouleur(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void colore(Color c){
|
public void colore(Color c){
|
||||||
this.setCouleur(c);
|
this.setCouleur(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean likeColor(PointColore pc) {
|
public boolean likeColor(PointColore pc) {
|
||||||
|
|
||||||
if(this.couleur == pc.couleur)
|
if(this.couleur == pc.couleur)
|
||||||
return true;
|
return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals (Object obj)
|
public boolean equals (Object obj)
|
||||||
{
|
{
|
||||||
Point p = (Point)obj;
|
Point p = (Point)obj;
|
||||||
if (super.x == p.x && super.y == p.y)
|
if (super.x == p.x && super.y == p.y)
|
||||||
return true;
|
return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointColore projX()
|
public PointColore projX()
|
||||||
{
|
{
|
||||||
Point p = super.projX();
|
Point p = super.projX();
|
||||||
return new PointColore(p.getX(), p.getY(), this.couleur);
|
return new PointColore(p.getX(), p.getY(), this.couleur);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointColore projY()
|
public PointColore projY()
|
||||||
{
|
{
|
||||||
Point p = super.projY();
|
Point p = super.projY();
|
||||||
return new PointColore(p.getY(), p.getY(), this.couleur);
|
return new PointColore(p.getY(), p.getY(), this.couleur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
98
TD5/src/pointcolore/TestPointColore.java → src/TD5/pointcolore/TestPointColore.java
Executable file → Normal file
98
TD5/src/pointcolore/TestPointColore.java → src/TD5/pointcolore/TestPointColore.java
Executable file → Normal file
@ -1,49 +1,49 @@
|
|||||||
package pointcolore;
|
package pointcolore;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
import point.Point;
|
import point.Point;
|
||||||
|
|
||||||
public class TestPointColore {
|
public class TestPointColore {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Point tableauPoint[] = new Point[11];
|
Point tableauPoint[] = new Point[11];
|
||||||
|
|
||||||
tableauPoint[0] = new Point(0., 5.);
|
tableauPoint[0] = new Point(0., 5.);
|
||||||
tableauPoint[1] = new Point(1., 4.);
|
tableauPoint[1] = new Point(1., 4.);
|
||||||
tableauPoint[2] = new Point(2., 3.);
|
tableauPoint[2] = new Point(2., 3.);
|
||||||
tableauPoint[3] = new Point(3., 2.);
|
tableauPoint[3] = new Point(3., 2.);
|
||||||
tableauPoint[4] = new Point(4., 1.);
|
tableauPoint[4] = new Point(4., 1.);
|
||||||
|
|
||||||
tableauPoint[5] = new PointColore(1., 1., Color.red);
|
tableauPoint[5] = new PointColore(1., 1., Color.red);
|
||||||
tableauPoint[6] = new PointColore(2., 1., Color.blue);
|
tableauPoint[6] = new PointColore(2., 1., Color.blue);
|
||||||
tableauPoint[7] = new PointColore(3., 3., Color.green);
|
tableauPoint[7] = new PointColore(3., 3., Color.green);
|
||||||
tableauPoint[8] = new PointColore(4., 4., Color.black);
|
tableauPoint[8] = new PointColore(4., 4., Color.black);
|
||||||
tableauPoint[9] = new PointColore(5., 5., Color.white);
|
tableauPoint[9] = new PointColore(5., 5., Color.white);
|
||||||
|
|
||||||
tableauPoint[10] = new PointColore();
|
tableauPoint[10] = new PointColore();
|
||||||
|
|
||||||
tableauPoint[10] = tableauPoint[6];
|
tableauPoint[10] = tableauPoint[6];
|
||||||
|
|
||||||
System.out.println("Test toString :");
|
System.out.println("Test toString :");
|
||||||
for (int i = 0; i < tableauPoint.length; i++) {
|
for (int i = 0; i < tableauPoint.length; i++) {
|
||||||
|
|
||||||
System.out.println("Le point d'incide " + i + " a pour attribus : " + tableauPoint[i].toString());
|
System.out.println("Le point d'incide " + i + " a pour attribus : " + tableauPoint[i].toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
System.out.println("Test getDistance :");
|
System.out.println("Test getDistance :");
|
||||||
for (int i = 0; i < (tableauPoint.length - 1); i++) {
|
for (int i = 0; i < (tableauPoint.length - 1); i++) {
|
||||||
System.out.println("La distance du point d'incide [" + i + "]-[" + (i+1) + "] est de " + tableauPoint[i].getDistance(tableauPoint[(i+1)]));
|
System.out.println("La distance du point d'incide [" + i + "]-[" + (i+1) + "] est de " + tableauPoint[i].getDistance(tableauPoint[(i+1)]));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
174
TD5/src/pokemon/Pokemon.java → src/TD5/pokemon/Pokemon.java
Executable file → Normal file
174
TD5/src/pokemon/Pokemon.java → src/TD5/pokemon/Pokemon.java
Executable file → Normal file
@ -1,87 +1,87 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class Pokemon {
|
public class Pokemon {
|
||||||
|
|
||||||
private String nom;
|
private String nom;
|
||||||
private double taille; // en m
|
private double taille; // en m
|
||||||
private double poids; // en kg
|
private double poids; // en kg
|
||||||
private int pv;
|
private int pv;
|
||||||
private int pc;
|
private int pc;
|
||||||
Type type;
|
Type type;
|
||||||
|
|
||||||
//getters
|
//getters
|
||||||
public String getNom() {
|
public String getNom() {
|
||||||
return nom;
|
return nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTaille() {
|
public double getTaille() {
|
||||||
return taille;
|
return taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPoids() {
|
public double getPoids() {
|
||||||
return poids;
|
return poids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPv() {
|
public int getPv() {
|
||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPc() {
|
public int getPc() {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
//setters
|
//setters
|
||||||
public void setNom(String nom) {
|
public void setNom(String nom) {
|
||||||
this.nom = nom;
|
this.nom = nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTaille(double taille) {
|
public void setTaille(double taille) {
|
||||||
this.taille = taille;
|
this.taille = taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPoids(double poids) {
|
public void setPoids(double poids) {
|
||||||
this.poids = poids;
|
this.poids = poids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPv(int pv) {
|
public void setPv(int pv) {
|
||||||
this.pv = pv;
|
this.pv = pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPc(int pc) {
|
public void setPc(int pc) {
|
||||||
this.pc = pc;
|
this.pc = pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(Type type) {
|
public void setType(Type type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pokemon() {
|
public Pokemon() {
|
||||||
nom = null;
|
nom = null;
|
||||||
taille = 0.;
|
taille = 0.;
|
||||||
poids = 0.;
|
poids = 0.;
|
||||||
pv = 0;
|
pv = 0;
|
||||||
pc = 0;
|
pc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pokemon(String n, double t, double p, int pv, int pc) {
|
public Pokemon(String n, double t, double p, int pv, int pc) {
|
||||||
this.nom = n;
|
this.nom = n;
|
||||||
this.taille = t;
|
this.taille = t;
|
||||||
this.poids = p;
|
this.poids = p;
|
||||||
this.pv = pv;
|
this.pv = pv;
|
||||||
this.pc = pc;
|
this.pc = pc;
|
||||||
this.type = null;
|
this.type = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
98
TD5/src/pokemon/PokemonEAU.java → src/TD5/pokemon/PokemonEAU.java
Executable file → Normal file
98
TD5/src/pokemon/PokemonEAU.java → src/TD5/pokemon/PokemonEAU.java
Executable file → Normal file
@ -1,49 +1,49 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class PokemonEAU extends Pokemon{
|
public class PokemonEAU extends Pokemon{
|
||||||
private int nb_nageoires;
|
private int nb_nageoires;
|
||||||
|
|
||||||
public PokemonEAU(String n, double t, double p, int pv, int pc, int g) {
|
public PokemonEAU(String n, double t, double p, int pv, int pc, int g) {
|
||||||
super.setNom(n);
|
super.setNom(n);
|
||||||
super.setTaille(t);
|
super.setTaille(t);
|
||||||
super.setPoids(p);
|
super.setPoids(p);
|
||||||
super.setPv(pv);
|
super.setPv(pv);
|
||||||
super.setPc(pc);
|
super.setPc(pc);
|
||||||
this.type = Type.EAU;
|
this.type = Type.EAU;
|
||||||
nb_nageoires = g;
|
nb_nageoires = g;
|
||||||
}
|
}
|
||||||
public int getNb_nageoires() {
|
public int getNb_nageoires() {
|
||||||
return nb_nageoires;
|
return nb_nageoires;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
this.setPv(Math.max(0, this.getPv() - modif));
|
this.setPv(Math.max(0, this.getPv() - modif));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return (this.getPoids() * nb_nageoires) / 25.0;
|
return (this.getPoids() * nb_nageoires) / 25.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Statistiques du Pokemon \"" + this.getNom() + "\" de type " + type.getDescription() + " : (" + this.getPoids() + " kg, "
|
return "Statistiques du Pokemon \"" + this.getNom() + "\" de type " + type.getDescription() + " : (" + this.getPoids() + " kg, "
|
||||||
+ this.getTaille() + " m, " + this.getPv() + " pts de vie, " + this.getPc() + " force de combat, " + nb_nageoires + " nageoires)";
|
+ this.getTaille() + " m, " + this.getPv() + " pts de vie, " + this.getPc() + " force de combat, " + nb_nageoires + " nageoires)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
if(p2.type == Type.ELECTRIK) {
|
if(p2.type == Type.ELECTRIK) {
|
||||||
p2.setPv(p2.getPv()-this.getPc());
|
p2.setPv(p2.getPv()-this.getPc());
|
||||||
}
|
}
|
||||||
else if(p2.type == Type.FEU) {
|
else if(p2.type == Type.FEU) {
|
||||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
122
TD5/src/pokemon/PokemonELECTRIK.java → src/TD5/pokemon/PokemonELECTRIK.java
Executable file → Normal file
122
TD5/src/pokemon/PokemonELECTRIK.java → src/TD5/pokemon/PokemonELECTRIK.java
Executable file → Normal file
@ -1,61 +1,61 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class PokemonELECTRIK extends Pokemon {
|
public class PokemonELECTRIK extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
private int nb_ailes;
|
private int nb_ailes;
|
||||||
private double intensite;
|
private double intensite;
|
||||||
|
|
||||||
public PokemonELECTRIK(String n, double t, double p, int pv, int pc, int g, int a, double i) {
|
public PokemonELECTRIK(String n, double t, double p, int pv, int pc, int g, int a, double i) {
|
||||||
super.setNom(n);
|
super.setNom(n);
|
||||||
super.setTaille(t);
|
super.setTaille(t);
|
||||||
super.setPoids(p);
|
super.setPoids(p);
|
||||||
super.setPv(pv);
|
super.setPv(pv);
|
||||||
super.setPc(pc);
|
super.setPc(pc);
|
||||||
this.type = Type.ELECTRIK;
|
this.type = Type.ELECTRIK;
|
||||||
nb_pattes = g;
|
nb_pattes = g;
|
||||||
nb_ailes = a;
|
nb_ailes = a;
|
||||||
intensite = i;
|
intensite = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getPattes() {
|
public int getPattes() {
|
||||||
return nb_pattes;
|
return nb_pattes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAiles() {
|
public int getAiles() {
|
||||||
return nb_ailes;
|
return nb_ailes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getIntensite() {
|
public double getIntensite() {
|
||||||
return intensite;
|
return intensite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
this.setPv(Math.max(0, this.getPv() - modif));
|
this.setPv(Math.max(0, this.getPv() - modif));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return (nb_ailes + nb_pattes) * intensite * 0.05;
|
return (nb_ailes + nb_pattes) * intensite * 0.05;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Statistiques du Pokemon \"" + this.getNom() + "\" de type " + type.getDescription() + " : (" + this.getPoids() + " kg, "
|
return "Statistiques du Pokemon \"" + this.getNom() + "\" de type " + type.getDescription() + " : (" + this.getPoids() + " kg, "
|
||||||
+ this.getTaille() + " m, " + this.getPv() + " pts de vie, " + this.getPc() + " force de combat, " + nb_pattes + " pattes, " + nb_ailes + " ailes, "
|
+ this.getTaille() + " m, " + this.getPv() + " pts de vie, " + this.getPc() + " force de combat, " + nb_pattes + " pattes, " + nb_ailes + " ailes, "
|
||||||
+ intensite + " mA)";
|
+ intensite + " mA)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
if(p2.type == Type.FEU) {
|
if(p2.type == Type.FEU) {
|
||||||
p2.setPv(p2.getPv()-this.getPc());
|
p2.setPv(p2.getPv()-this.getPc());
|
||||||
}
|
}
|
||||||
else if(p2.type == Type.EAU) {
|
else if(p2.type == Type.EAU) {
|
||||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
98
TD5/src/pokemon/PokemonFEU.java → src/TD5/pokemon/PokemonFEU.java
Executable file → Normal file
98
TD5/src/pokemon/PokemonFEU.java → src/TD5/pokemon/PokemonFEU.java
Executable file → Normal file
@ -1,49 +1,49 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class PokemonFEU extends Pokemon {
|
public class PokemonFEU extends Pokemon {
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
|
||||||
public PokemonFEU(String n, double t, double p, int pv, int pc, int g) {
|
public PokemonFEU(String n, double t, double p, int pv, int pc, int g) {
|
||||||
super.setNom(n);
|
super.setNom(n);
|
||||||
super.setTaille(t);
|
super.setTaille(t);
|
||||||
super.setPoids(p);
|
super.setPoids(p);
|
||||||
super.setPv(pv);
|
super.setPv(pv);
|
||||||
super.setPc(pc);
|
super.setPc(pc);
|
||||||
this.type = Type.FEU;
|
this.type = Type.FEU;
|
||||||
nb_pattes = g;
|
nb_pattes = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPattes() {
|
public int getPattes() {
|
||||||
return nb_pattes;
|
return nb_pattes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
this.setPv(Math.max(0, this.getPv() - modif));
|
this.setPv(Math.max(0, this.getPv() - modif));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return this.getPoids() * nb_pattes * 0.03;
|
return this.getPoids() * nb_pattes * 0.03;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Statistiques du Pokemon \"" + this.getNom() + "\" de type " + type.getDescription() + " : (" + this.getPoids() + " kg, "
|
return "Statistiques du Pokemon \"" + this.getNom() + "\" de type " + type.getDescription() + " : (" + this.getPoids() + " kg, "
|
||||||
+ this.getTaille() + " m, " + this.getPv() + " pts de vie, " + this.getPc() + " force de combat, "
|
+ this.getTaille() + " m, " + this.getPv() + " pts de vie, " + this.getPc() + " force de combat, "
|
||||||
+ nb_pattes + " pattes)";
|
+ nb_pattes + " pattes)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
if(p2.type == Type.FEU) {
|
if(p2.type == Type.FEU) {
|
||||||
p2.setPv(p2.getPv()-this.getPc());
|
p2.setPv(p2.getPv()-this.getPc());
|
||||||
}
|
}
|
||||||
else if(p2.type == Type.PLANTE) {
|
else if(p2.type == Type.PLANTE) {
|
||||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
82
TD5/src/pokemon/PokemonPLANTE.java → src/TD5/pokemon/PokemonPLANTE.java
Executable file → Normal file
82
TD5/src/pokemon/PokemonPLANTE.java → src/TD5/pokemon/PokemonPLANTE.java
Executable file → Normal file
@ -1,42 +1,42 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class PokemonPLANTE extends Pokemon{
|
public class PokemonPLANTE extends Pokemon{
|
||||||
|
|
||||||
public PokemonPLANTE(String n, double t, double p, int pv, int pc) {
|
public PokemonPLANTE(String n, double t, double p, int pv, int pc) {
|
||||||
super.setNom(n);
|
super.setNom(n);
|
||||||
super.setTaille(t);
|
super.setTaille(t);
|
||||||
super.setPoids(p);
|
super.setPoids(p);
|
||||||
super.setPv(pv);
|
super.setPv(pv);
|
||||||
super.setPc(pc);
|
super.setPc(pc);
|
||||||
this.type = Type.PLANTE;
|
this.type = Type.PLANTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
this.setPv(Math.max(0, this.getPv() - modif));
|
this.setPv(Math.max(0, this.getPv() - modif));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return 10.0 / (this.getPoids() * this.getTaille());
|
return 10.0 / (this.getPoids() * this.getTaille());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Statistiques du Pokemon \"" + this.getNom() + "\" de type " + type.getDescription() + " : (" + this.getPoids() + " kg, "
|
return "Statistiques du Pokemon \"" + this.getNom() + "\" de type " + type.getDescription() + " : (" + this.getPoids() + " kg, "
|
||||||
+ this.getTaille() + " m, " + this.getPv() + " pts de vie, " + this.getPc() + " force de combat)";
|
+ this.getTaille() + " m, " + this.getPv() + " pts de vie, " + this.getPc() + " force de combat)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double attack(Pokemon p2) {
|
public double attack(Pokemon p2) {
|
||||||
if(p2.type == Type.EAU) {
|
if(p2.type == Type.EAU) {
|
||||||
p2.setPv(p2.getPv()-this.getPc());
|
p2.setPv(p2.getPv()-this.getPc());
|
||||||
}
|
}
|
||||||
else if(p2.type == Type.ELECTRIK) {
|
else if(p2.type == Type.ELECTRIK) {
|
||||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
112
TD5/src/pokemon/TestPokemon.java → src/TD5/pokemon/TestPokemon.java
Executable file → Normal file
112
TD5/src/pokemon/TestPokemon.java → src/TD5/pokemon/TestPokemon.java
Executable file → Normal file
@ -1,56 +1,56 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
public class TestPokemon {
|
public class TestPokemon {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Pokemon tabPKM[] = new Pokemon[8];
|
Pokemon tabPKM[] = new Pokemon[8];
|
||||||
|
|
||||||
//fire
|
//fire
|
||||||
PokemonFEU Infernape = new PokemonFEU("Infernape", 1.2, 55., 356, 45, 4);
|
PokemonFEU Infernape = new PokemonFEU("Infernape", 1.2, 55., 356, 45, 4);
|
||||||
PokemonFEU Ninetales = new PokemonFEU("Ninetales", 1.1, 19.9, 350, 26, 4);
|
PokemonFEU Ninetales = new PokemonFEU("Ninetales", 1.1, 19.9, 350, 26, 4);
|
||||||
|
|
||||||
//Electric
|
//Electric
|
||||||
PokemonELECTRIK Ampharos = new PokemonELECTRIK("Ampharos", 1.4, 61.5, 384, 32, 2, 0, 95);
|
PokemonELECTRIK Ampharos = new PokemonELECTRIK("Ampharos", 1.4, 61.5, 384, 32, 2, 0, 95);
|
||||||
PokemonELECTRIK RaichuA = new PokemonELECTRIK("Raichu Alolan Form", .7, 21., 324, 37, 2, 0, 105);
|
PokemonELECTRIK RaichuA = new PokemonELECTRIK("Raichu Alolan Form", .7, 21., 324, 37, 2, 0, 105);
|
||||||
|
|
||||||
//water
|
//water
|
||||||
PokemonEAU Ludicolo = new PokemonEAU("Ludicolo", 1.5, 55., 364, 45, 2);
|
PokemonEAU Ludicolo = new PokemonEAU("Ludicolo", 1.5, 55., 364, 45, 2);
|
||||||
PokemonEAU Froakie = new PokemonEAU("Froakie", .3, 7., 286, 20, 2);
|
PokemonEAU Froakie = new PokemonEAU("Froakie", .3, 7., 286, 20, 2);
|
||||||
|
|
||||||
//grass
|
//grass
|
||||||
PokemonPLANTE Roselia = new PokemonPLANTE("Roselia", .3, 2., 304, 14);
|
PokemonPLANTE Roselia = new PokemonPLANTE("Roselia", .3, 2., 304, 14);
|
||||||
PokemonPLANTE Torterra = new PokemonPLANTE("Torterra", 2.2, 310., 394, 44);
|
PokemonPLANTE Torterra = new PokemonPLANTE("Torterra", 2.2, 310., 394, 44);
|
||||||
|
|
||||||
tabPKM[0] = Infernape;
|
tabPKM[0] = Infernape;
|
||||||
tabPKM[1] = Ninetales;
|
tabPKM[1] = Ninetales;
|
||||||
tabPKM[2] = Ampharos;
|
tabPKM[2] = Ampharos;
|
||||||
tabPKM[3] = RaichuA;
|
tabPKM[3] = RaichuA;
|
||||||
tabPKM[4] = Ludicolo;
|
tabPKM[4] = Ludicolo;
|
||||||
tabPKM[5] = Froakie;
|
tabPKM[5] = Froakie;
|
||||||
tabPKM[6] = Roselia;
|
tabPKM[6] = Roselia;
|
||||||
tabPKM[7] = Torterra;
|
tabPKM[7] = Torterra;
|
||||||
|
|
||||||
for (int i = 0; i < tabPKM.length; i++) {
|
for (int i = 0; i < tabPKM.length; i++) {
|
||||||
System.out.println(tabPKM[i].toString());
|
System.out.println(tabPKM[i].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Infernape.attack(Ludicolo);
|
Infernape.attack(Ludicolo);
|
||||||
Ludicolo.attack(Froakie);
|
Ludicolo.attack(Froakie);
|
||||||
Froakie.attack(Infernape);
|
Froakie.attack(Infernape);
|
||||||
Torterra.attack(Roselia);
|
Torterra.attack(Roselia);
|
||||||
Roselia.attack(RaichuA);
|
Roselia.attack(RaichuA);
|
||||||
RaichuA.attack(Ninetales);
|
RaichuA.attack(Ninetales);
|
||||||
Ninetales.attack(Roselia);
|
Ninetales.attack(Roselia);
|
||||||
Torterra.attack(Roselia);
|
Torterra.attack(Roselia);
|
||||||
|
|
||||||
System.out.println("=========================================================================");
|
System.out.println("=========================================================================");
|
||||||
|
|
||||||
for (int i = 0; i < tabPKM.length; i++) {
|
for (int i = 0; i < tabPKM.length; i++) {
|
||||||
System.out.println(tabPKM[i].toString());
|
System.out.println(tabPKM[i].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Hello Pokeworld !");
|
System.out.println("Hello Pokeworld !");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
38
TD10/src/pokemon/Type.java → src/TD5/pokemon/Type.java
Executable file → Normal file
38
TD10/src/pokemon/Type.java → src/TD5/pokemon/Type.java
Executable file → Normal file
@ -1,19 +1,19 @@
|
|||||||
package pokemon;
|
package pokemon;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
|
|
||||||
EAU("EAU"),
|
EAU("EAU"),
|
||||||
ELECTRIK("ELECTRIK"),
|
ELECTRIK("ELECTRIK"),
|
||||||
FEU("FEU"),
|
FEU("FEU"),
|
||||||
PLANTE("PLANTE");
|
PLANTE("PLANTE");
|
||||||
|
|
||||||
Type(String s) {
|
Type(String s) {
|
||||||
description = s;
|
description = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
}
|
}
|
0
TD6/src/pkmA/Attaque.java → src/TD6/pkmA/Attaque.java
Executable file → Normal file
0
TD6/src/pkmA/Attaque.java → src/TD6/pkmA/Attaque.java
Executable file → Normal file
0
TD6/src/pkmA/Pokemon.java → src/TD6/pkmA/Pokemon.java
Executable file → Normal file
0
TD6/src/pkmA/Pokemon.java → src/TD6/pkmA/Pokemon.java
Executable file → Normal file
152
TD6/src/pkmA/PokemonEAU.java → src/TD6/pkmA/PokemonEAU.java
Executable file → Normal file
152
TD6/src/pkmA/PokemonEAU.java → src/TD6/pkmA/PokemonEAU.java
Executable file → Normal file
@ -1,76 +1,76 @@
|
|||||||
package pkmA;
|
package pkmA;
|
||||||
|
|
||||||
public class PokemonEAU extends Pokemon{
|
public class PokemonEAU extends Pokemon{
|
||||||
private String nom;
|
private String nom;
|
||||||
private double taille; // en m
|
private double taille; // en m
|
||||||
private double poids; // en kg
|
private double poids; // en kg
|
||||||
private int pv;
|
private int pv;
|
||||||
private int pc;
|
private int pc;
|
||||||
Type type;
|
Type type;
|
||||||
private int nb_nageoires;
|
private int nb_nageoires;
|
||||||
|
|
||||||
public PokemonEAU() {
|
public PokemonEAU() {
|
||||||
type = Type.EAU;
|
type = Type.EAU;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PokemonEAU(String n, double t, double p, int v, int c, int g) {
|
public PokemonEAU(String n, double t, double p, int v, int c, int g) {
|
||||||
super(n, t, p, v, c, Type.EAU);
|
super(n, t, p, v, c, Type.EAU);
|
||||||
this.nom = n;
|
this.nom = n;
|
||||||
this.type = Type.EAU;
|
this.type = Type.EAU;
|
||||||
nb_nageoires = g;
|
nb_nageoires = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNom() {
|
public String getNom() {
|
||||||
return nom;
|
return nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTaille() {
|
public double getTaille() {
|
||||||
return taille;
|
return taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPoids() {
|
public double getPoids() {
|
||||||
return poids;
|
return poids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPv() {
|
public int getPv() {
|
||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPc() {
|
public int getPc() {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNb_nageoires() {
|
public int getNb_nageoires() {
|
||||||
return nb_nageoires;
|
return nb_nageoires;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
pv = Math.max(0, pv-modif);
|
pv = Math.max(0, pv-modif);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return (this.poids*nb_nageoires)/25.0;
|
return (this.poids*nb_nageoires)/25.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attaquer(Pokemon adv) {
|
public void attaquer(Pokemon adv) {
|
||||||
if (adv.getType() == Type.EAU || adv.getType() == Type.PLANTE) {
|
if (adv.getType() == Type.EAU || adv.getType() == Type.PLANTE) {
|
||||||
adv.changePv(Math.round(super.getPc()/2));
|
adv.changePv(Math.round(super.getPc()/2));
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
||||||
} else if (adv.getType() == Type.ELECTRIK) {
|
} else if (adv.getType() == Type.ELECTRIK) {
|
||||||
adv.changePv(super.getPc());
|
adv.changePv(super.getPc());
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
||||||
} else {
|
} else {
|
||||||
adv.changePv(2*super.getPc());
|
adv.changePv(2*super.getPc());
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+2*pc+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+2*pc+" a "+adv.getNom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
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)";
|
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)";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
174
TD6/src/pkmA/PokemonELECTRIK.java → src/TD6/pkmA/PokemonELECTRIK.java
Executable file → Normal file
174
TD6/src/pkmA/PokemonELECTRIK.java → src/TD6/pkmA/PokemonELECTRIK.java
Executable file → Normal file
@ -1,87 +1,87 @@
|
|||||||
package pkmA;
|
package pkmA;
|
||||||
|
|
||||||
public class PokemonELECTRIK extends Pokemon{
|
public class PokemonELECTRIK extends Pokemon{
|
||||||
private String nom;
|
private String nom;
|
||||||
private double taille; // en m
|
private double taille; // en m
|
||||||
private double poids; // en kg
|
private double poids; // en kg
|
||||||
private int pv;
|
private int pv;
|
||||||
private int pc;
|
private int pc;
|
||||||
Type type;
|
Type type;
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
private int nb_ailes;
|
private int nb_ailes;
|
||||||
private double intensite;
|
private double intensite;
|
||||||
|
|
||||||
public PokemonELECTRIK() {
|
public PokemonELECTRIK() {
|
||||||
type = Type.ELECTRIK;
|
type = Type.ELECTRIK;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PokemonELECTRIK(String n, double t, double p, int v, int c, int g, int a, double i) {
|
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);
|
super(n, t, p, v, c, Type.ELECTRIK);
|
||||||
this.nom = n;
|
this.nom = n;
|
||||||
this.type = Type.ELECTRIK;
|
this.type = Type.ELECTRIK;
|
||||||
nb_pattes = g;
|
nb_pattes = g;
|
||||||
nb_ailes = a;
|
nb_ailes = a;
|
||||||
intensite = i;
|
intensite = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNom() {
|
public String getNom() {
|
||||||
return nom;
|
return nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTaille() {
|
public double getTaille() {
|
||||||
return taille;
|
return taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPoids() {
|
public double getPoids() {
|
||||||
return poids;
|
return poids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPv() {
|
public int getPv() {
|
||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPc() {
|
public int getPc() {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPattes() {
|
public int getPattes() {
|
||||||
return nb_pattes;
|
return nb_pattes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAiles() {
|
public int getAiles() {
|
||||||
return nb_ailes;
|
return nb_ailes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getIntensite() {
|
public double getIntensite() {
|
||||||
return intensite;
|
return intensite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
pv = Math.max(0, pv-modif);
|
pv = Math.max(0, pv-modif);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return (nb_ailes+nb_pattes) * intensite * 0.05;
|
return (nb_ailes+nb_pattes) * intensite * 0.05;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attaquer(Pokemon adv) {
|
public void attaquer(Pokemon adv) {
|
||||||
if (adv.getType() == Type.ELECTRIK || adv.getType() == Type.PLANTE) {
|
if (adv.getType() == Type.ELECTRIK || adv.getType() == Type.PLANTE) {
|
||||||
adv.changePv(Math.round(super.getPc()/2));
|
adv.changePv(Math.round(super.getPc()/2));
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
||||||
} else if (adv.getType() == Type.FEU) {
|
} else if (adv.getType() == Type.FEU) {
|
||||||
adv.changePv(super.getPc());
|
adv.changePv(super.getPc());
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
||||||
} else {
|
} else {
|
||||||
adv.changePv(2*super.getPc());
|
adv.changePv(2*super.getPc());
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
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)";
|
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)";
|
||||||
}
|
}
|
||||||
}
|
}
|
152
TD6/src/pkmA/PokemonFEU.java → src/TD6/pkmA/PokemonFEU.java
Executable file → Normal file
152
TD6/src/pkmA/PokemonFEU.java → src/TD6/pkmA/PokemonFEU.java
Executable file → Normal file
@ -1,76 +1,76 @@
|
|||||||
package pkmA;
|
package pkmA;
|
||||||
|
|
||||||
public class PokemonFEU extends Pokemon{
|
public class PokemonFEU extends Pokemon{
|
||||||
private String nom;
|
private String nom;
|
||||||
private double taille; // en m
|
private double taille; // en m
|
||||||
private double poids; // en kg
|
private double poids; // en kg
|
||||||
private int pv;
|
private int pv;
|
||||||
private int pc;
|
private int pc;
|
||||||
Type type;
|
Type type;
|
||||||
private int nb_pattes;
|
private int nb_pattes;
|
||||||
|
|
||||||
public PokemonFEU() {
|
public PokemonFEU() {
|
||||||
type = Type.FEU;
|
type = Type.FEU;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PokemonFEU(String n, double t, double p, int v, int c, int g) {
|
public PokemonFEU(String n, double t, double p, int v, int c, int g) {
|
||||||
super(n, t, p, v, c, Type.FEU);
|
super(n, t, p, v, c, Type.FEU);
|
||||||
this.nom = n;
|
this.nom = n;
|
||||||
this.type = Type.FEU;
|
this.type = Type.FEU;
|
||||||
nb_pattes = g;
|
nb_pattes = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNom() {
|
public String getNom() {
|
||||||
return nom;
|
return nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTaille() {
|
public double getTaille() {
|
||||||
return taille;
|
return taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPoids() {
|
public double getPoids() {
|
||||||
return poids;
|
return poids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPv() {
|
public int getPv() {
|
||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPc() {
|
public int getPc() {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPattes() {
|
public int getPattes() {
|
||||||
return nb_pattes;
|
return nb_pattes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
pv = Math.max(0, pv-modif);
|
pv = Math.max(0, pv-modif);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return this.getPoids()*nb_pattes* 0.03;
|
return this.getPoids()*nb_pattes* 0.03;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attaquer(Pokemon adv) {
|
public void attaquer(Pokemon adv) {
|
||||||
if (adv.getType() == Type.EAU || adv.getType() == Type.ELECTRIK) {
|
if (adv.getType() == Type.EAU || adv.getType() == Type.ELECTRIK) {
|
||||||
adv.changePv(Math.round(super.getPc()/2));
|
adv.changePv(Math.round(super.getPc()/2));
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
||||||
} else if (adv.getType() == Type.FEU) {
|
} else if (adv.getType() == Type.FEU) {
|
||||||
adv.changePv(super.getPc());
|
adv.changePv(super.getPc());
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
||||||
} else {
|
} else {
|
||||||
adv.changePv(2*super.getPc());
|
adv.changePv(2*super.getPc());
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+2*super.getPc()+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+2*super.getPc()+" a "+adv.getNom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
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)";
|
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)";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
140
TD6/src/pkmA/PokemonPLANTE.java → src/TD6/pkmA/PokemonPLANTE.java
Executable file → Normal file
140
TD6/src/pkmA/PokemonPLANTE.java → src/TD6/pkmA/PokemonPLANTE.java
Executable file → Normal file
@ -1,70 +1,70 @@
|
|||||||
package pkmA;
|
package pkmA;
|
||||||
|
|
||||||
public class PokemonPLANTE extends Pokemon{
|
public class PokemonPLANTE extends Pokemon{
|
||||||
private String nom;
|
private String nom;
|
||||||
private double taille; // en m
|
private double taille; // en m
|
||||||
private double poids; // en kg
|
private double poids; // en kg
|
||||||
private int pv;
|
private int pv;
|
||||||
private int pc;
|
private int pc;
|
||||||
Type type;
|
Type type;
|
||||||
|
|
||||||
public PokemonPLANTE() {
|
public PokemonPLANTE() {
|
||||||
type = Type.PLANTE;
|
type = Type.PLANTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PokemonPLANTE(String n, double t, double p, int v, int c) {
|
public PokemonPLANTE(String n, double t, double p, int v, int c) {
|
||||||
super(n, t, p, v, c, Type.PLANTE);
|
super(n, t, p, v, c, Type.PLANTE);
|
||||||
this.nom = n;
|
this.nom = n;
|
||||||
this.type = Type.PLANTE;
|
this.type = Type.PLANTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNom() {
|
public String getNom() {
|
||||||
return nom;
|
return nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTaille() {
|
public double getTaille() {
|
||||||
return taille;
|
return taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPoids() {
|
public double getPoids() {
|
||||||
return poids;
|
return poids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPv() {
|
public int getPv() {
|
||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPc() {
|
public int getPc() {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePv(int modif) {
|
public void changePv(int modif) {
|
||||||
pv = Math.max(0, pv-modif);
|
pv = Math.max(0, pv-modif);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calculerVitesse() {
|
public double calculerVitesse() {
|
||||||
return 10.0 / (this.getPoids()*this.getTaille());
|
return 10.0 / (this.getPoids()*this.getTaille());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attaquer(Pokemon adv) {
|
public void attaquer(Pokemon adv) {
|
||||||
if (adv.getType() == Type.FEU || adv.getType() == Type.PLANTE) {
|
if (adv.getType() == Type.FEU || adv.getType() == Type.PLANTE) {
|
||||||
adv.changePv(Math.round(super.getPc()/2));
|
adv.changePv(Math.round(super.getPc()/2));
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+Math.round(super.getPc()/2)+" a "+adv.getNom());
|
||||||
} else if (adv.getType() == Type.EAU) {
|
} else if (adv.getType() == Type.EAU) {
|
||||||
adv.changePv(super.getPc());
|
adv.changePv(super.getPc());
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+super.getPc()+" a "+adv.getNom());
|
||||||
} else {
|
} else {
|
||||||
adv.changePv(2*super.getPc());
|
adv.changePv(2*super.getPc());
|
||||||
System.out.println(""+this.getNom()+" inflige "+""+2*super.getPc()+" a "+adv.getNom());
|
System.out.println(""+this.getNom()+" inflige "+""+2*super.getPc()+" a "+adv.getNom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
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),";
|
return "Pokemon "+super.getNom()+" de type "+type.getDescription()+" ("+super.getPoids()+" kg, "+super.getTaille()+" m, "+super.getPv()+" pts de vie, "+super.getPc()+" force de combat),";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
0
TD6/src/pkmA/TestPokemon.java → src/TD6/pkmA/TestPokemon.java
Executable file → Normal file
0
TD6/src/pkmA/TestPokemon.java → src/TD6/pkmA/TestPokemon.java
Executable file → Normal file
22
TD6/src/pkmA/Type.java → src/TD6/pkmA/Type.java
Executable file → Normal file
22
TD6/src/pkmA/Type.java → src/TD6/pkmA/Type.java
Executable file → Normal file
@ -1,11 +1,11 @@
|
|||||||
package pkmA;
|
package pkmA;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
EAU ("EAU"),
|
EAU ("EAU"),
|
||||||
ELECTRIK ("ELECTRIK"),
|
ELECTRIK ("ELECTRIK"),
|
||||||
FEU ("FEU"),
|
FEU ("FEU"),
|
||||||
PLANTE ("PLANTE");
|
PLANTE ("PLANTE");
|
||||||
Type(String s){description = s;}
|
Type(String s){description = s;}
|
||||||
private String description;
|
private String description;
|
||||||
public String getDescription() {return description;}
|
public String getDescription() {return description;}
|
||||||
}
|
}
|
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