"depot M213"
This commit is contained in:
BIN
TD5/TD5.pdf
Executable file
BIN
TD5/TD5.pdf
Executable file
Binary file not shown.
78
TD5/src/pointcolore/PointColore.java
Executable file
78
TD5/src/pointcolore/PointColore.java
Executable file
@ -0,0 +1,78 @@
|
||||
package pointcolore;
|
||||
|
||||
import java.awt.Color;
|
||||
import point.Point;
|
||||
|
||||
public class PointColore extends Point {
|
||||
|
||||
private Color couleur;
|
||||
|
||||
//==================================================
|
||||
|
||||
public Color getCouleur() {
|
||||
return couleur;
|
||||
}
|
||||
|
||||
public void setCouleur(Color couleur) {
|
||||
this.couleur = couleur;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " - Couleur : " + couleur + ")";
|
||||
}
|
||||
|
||||
//==================================================
|
||||
|
||||
public PointColore() {
|
||||
this.setCouleur(Color.black);
|
||||
}
|
||||
|
||||
public PointColore(double x, double y, Color c) {
|
||||
super(x,y);
|
||||
this.setCouleur(c);
|
||||
}
|
||||
|
||||
public void colore(Color c){
|
||||
this.setCouleur(c);
|
||||
}
|
||||
|
||||
public boolean likeColor(PointColore pc) {
|
||||
|
||||
if(this.couleur == pc.couleur)
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object obj)
|
||||
{
|
||||
Point p = (Point)obj;
|
||||
if (super.x == p.x && super.y == p.y)
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
public PointColore projX()
|
||||
{
|
||||
Point p = super.projX();
|
||||
return new PointColore(p.getX(), p.getY(), this.couleur);
|
||||
}
|
||||
|
||||
public PointColore projY()
|
||||
{
|
||||
Point p = super.projY();
|
||||
return new PointColore(p.getY(), p.getY(), this.couleur);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
49
TD5/src/pointcolore/TestPointColore.java
Executable file
49
TD5/src/pointcolore/TestPointColore.java
Executable file
@ -0,0 +1,49 @@
|
||||
package pointcolore;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import point.Point;
|
||||
|
||||
public class TestPointColore {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Point tableauPoint[] = new Point[11];
|
||||
|
||||
tableauPoint[0] = new Point(0., 5.);
|
||||
tableauPoint[1] = new Point(1., 4.);
|
||||
tableauPoint[2] = new Point(2., 3.);
|
||||
tableauPoint[3] = new Point(3., 2.);
|
||||
tableauPoint[4] = new Point(4., 1.);
|
||||
|
||||
tableauPoint[5] = new PointColore(1., 1., Color.red);
|
||||
tableauPoint[6] = new PointColore(2., 1., Color.blue);
|
||||
tableauPoint[7] = new PointColore(3., 3., Color.green);
|
||||
tableauPoint[8] = new PointColore(4., 4., Color.black);
|
||||
tableauPoint[9] = new PointColore(5., 5., Color.white);
|
||||
|
||||
tableauPoint[10] = new PointColore();
|
||||
|
||||
tableauPoint[10] = tableauPoint[6];
|
||||
|
||||
System.out.println("Test toString :");
|
||||
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("Test getDistance :");
|
||||
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)]));
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
87
TD5/src/pokemon/Pokemon.java
Executable file
87
TD5/src/pokemon/Pokemon.java
Executable file
@ -0,0 +1,87 @@
|
||||
package pokemon;
|
||||
|
||||
public class Pokemon {
|
||||
|
||||
private String nom;
|
||||
private double taille; // en m
|
||||
private double poids; // en kg
|
||||
private int pv;
|
||||
private int pc;
|
||||
Type type;
|
||||
|
||||
//getters
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public double getTaille() {
|
||||
return taille;
|
||||
}
|
||||
|
||||
public double getPoids() {
|
||||
return poids;
|
||||
}
|
||||
|
||||
public int getPv() {
|
||||
return pv;
|
||||
}
|
||||
|
||||
public int getPc() {
|
||||
return pc;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
//setters
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public void setTaille(double taille) {
|
||||
this.taille = taille;
|
||||
}
|
||||
|
||||
public void setPoids(double poids) {
|
||||
this.poids = poids;
|
||||
}
|
||||
|
||||
public void setPv(int pv) {
|
||||
this.pv = pv;
|
||||
}
|
||||
|
||||
public void setPc(int pc) {
|
||||
this.pc = pc;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Pokemon() {
|
||||
nom = null;
|
||||
taille = 0.;
|
||||
poids = 0.;
|
||||
pv = 0;
|
||||
pc = 0;
|
||||
}
|
||||
|
||||
public Pokemon(String n, double t, double p, int pv, int pc) {
|
||||
this.nom = n;
|
||||
this.taille = t;
|
||||
this.poids = p;
|
||||
this.pv = pv;
|
||||
this.pc = pc;
|
||||
this.type = null;
|
||||
}
|
||||
|
||||
public double calculerVitesse() {
|
||||
return 0.;
|
||||
}
|
||||
|
||||
public double attack(Pokemon p2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
49
TD5/src/pokemon/PokemonEAU.java
Executable file
49
TD5/src/pokemon/PokemonEAU.java
Executable file
@ -0,0 +1,49 @@
|
||||
package pokemon;
|
||||
|
||||
public class PokemonEAU extends Pokemon{
|
||||
private int nb_nageoires;
|
||||
|
||||
public PokemonEAU(String n, double t, double p, int pv, int pc, int g) {
|
||||
super.setNom(n);
|
||||
super.setTaille(t);
|
||||
super.setPoids(p);
|
||||
super.setPv(pv);
|
||||
super.setPc(pc);
|
||||
this.type = Type.EAU;
|
||||
nb_nageoires = g;
|
||||
}
|
||||
public int getNb_nageoires() {
|
||||
return nb_nageoires;
|
||||
}
|
||||
|
||||
public void changePv(int modif) {
|
||||
this.setPv(Math.max(0, this.getPv() - modif));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calculerVitesse() {
|
||||
return (this.getPoids() * nb_nageoires) / 25.0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
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)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double attack(Pokemon p2) {
|
||||
if(p2.type == Type.ELECTRIK) {
|
||||
p2.setPv(p2.getPv()-this.getPc());
|
||||
}
|
||||
else if(p2.type == Type.FEU) {
|
||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||
}
|
||||
else {
|
||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
61
TD5/src/pokemon/PokemonELECTRIK.java
Executable file
61
TD5/src/pokemon/PokemonELECTRIK.java
Executable file
@ -0,0 +1,61 @@
|
||||
package pokemon;
|
||||
|
||||
public class PokemonELECTRIK extends Pokemon {
|
||||
private int nb_pattes;
|
||||
private int nb_ailes;
|
||||
private double intensite;
|
||||
|
||||
public PokemonELECTRIK(String n, double t, double p, int pv, int pc, int g, int a, double i) {
|
||||
super.setNom(n);
|
||||
super.setTaille(t);
|
||||
super.setPoids(p);
|
||||
super.setPv(pv);
|
||||
super.setPc(pc);
|
||||
this.type = Type.ELECTRIK;
|
||||
nb_pattes = g;
|
||||
nb_ailes = a;
|
||||
intensite = i;
|
||||
}
|
||||
|
||||
|
||||
public int getPattes() {
|
||||
return nb_pattes;
|
||||
}
|
||||
|
||||
public int getAiles() {
|
||||
return nb_ailes;
|
||||
}
|
||||
|
||||
public double getIntensite() {
|
||||
return intensite;
|
||||
}
|
||||
|
||||
public void changePv(int modif) {
|
||||
this.setPv(Math.max(0, this.getPv() - modif));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calculerVitesse() {
|
||||
return (nb_ailes + nb_pattes) * intensite * 0.05;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
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, "
|
||||
+ intensite + " mA)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double attack(Pokemon p2) {
|
||||
if(p2.type == Type.FEU) {
|
||||
p2.setPv(p2.getPv()-this.getPc());
|
||||
}
|
||||
else if(p2.type == Type.EAU) {
|
||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||
}
|
||||
else {
|
||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
49
TD5/src/pokemon/PokemonFEU.java
Executable file
49
TD5/src/pokemon/PokemonFEU.java
Executable file
@ -0,0 +1,49 @@
|
||||
package pokemon;
|
||||
|
||||
public class PokemonFEU extends Pokemon {
|
||||
private int nb_pattes;
|
||||
|
||||
public PokemonFEU(String n, double t, double p, int pv, int pc, int g) {
|
||||
super.setNom(n);
|
||||
super.setTaille(t);
|
||||
super.setPoids(p);
|
||||
super.setPv(pv);
|
||||
super.setPc(pc);
|
||||
this.type = Type.FEU;
|
||||
nb_pattes = g;
|
||||
}
|
||||
|
||||
public int getPattes() {
|
||||
return nb_pattes;
|
||||
}
|
||||
|
||||
public void changePv(int modif) {
|
||||
this.setPv(Math.max(0, this.getPv() - modif));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calculerVitesse() {
|
||||
return this.getPoids() * nb_pattes * 0.03;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
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)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double attack(Pokemon p2) {
|
||||
if(p2.type == Type.FEU) {
|
||||
p2.setPv(p2.getPv()-this.getPc());
|
||||
}
|
||||
else if(p2.type == Type.PLANTE) {
|
||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||
}
|
||||
else {
|
||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
42
TD5/src/pokemon/PokemonPLANTE.java
Executable file
42
TD5/src/pokemon/PokemonPLANTE.java
Executable file
@ -0,0 +1,42 @@
|
||||
package pokemon;
|
||||
|
||||
public class PokemonPLANTE extends Pokemon{
|
||||
|
||||
public PokemonPLANTE(String n, double t, double p, int pv, int pc) {
|
||||
super.setNom(n);
|
||||
super.setTaille(t);
|
||||
super.setPoids(p);
|
||||
super.setPv(pv);
|
||||
super.setPc(pc);
|
||||
this.type = Type.PLANTE;
|
||||
}
|
||||
|
||||
public void changePv(int modif) {
|
||||
this.setPv(Math.max(0, this.getPv() - modif));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calculerVitesse() {
|
||||
return 10.0 / (this.getPoids() * this.getTaille());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
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)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double attack(Pokemon p2) {
|
||||
if(p2.type == Type.EAU) {
|
||||
p2.setPv(p2.getPv()-this.getPc());
|
||||
}
|
||||
else if(p2.type == Type.ELECTRIK) {
|
||||
p2.setPv((p2.getPv()-this.getPc()*2));
|
||||
}
|
||||
else {
|
||||
p2.setPv((p2.getPv()-this.getPc()/2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
56
TD5/src/pokemon/TestPokemon.java
Executable file
56
TD5/src/pokemon/TestPokemon.java
Executable file
@ -0,0 +1,56 @@
|
||||
package pokemon;
|
||||
|
||||
public class TestPokemon {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Pokemon tabPKM[] = new Pokemon[8];
|
||||
|
||||
//fire
|
||||
PokemonFEU Infernape = new PokemonFEU("Infernape", 1.2, 55., 356, 45, 4);
|
||||
PokemonFEU Ninetales = new PokemonFEU("Ninetales", 1.1, 19.9, 350, 26, 4);
|
||||
|
||||
//Electric
|
||||
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);
|
||||
|
||||
//water
|
||||
PokemonEAU Ludicolo = new PokemonEAU("Ludicolo", 1.5, 55., 364, 45, 2);
|
||||
PokemonEAU Froakie = new PokemonEAU("Froakie", .3, 7., 286, 20, 2);
|
||||
|
||||
//grass
|
||||
PokemonPLANTE Roselia = new PokemonPLANTE("Roselia", .3, 2., 304, 14);
|
||||
PokemonPLANTE Torterra = new PokemonPLANTE("Torterra", 2.2, 310., 394, 44);
|
||||
|
||||
tabPKM[0] = Infernape;
|
||||
tabPKM[1] = Ninetales;
|
||||
tabPKM[2] = Ampharos;
|
||||
tabPKM[3] = RaichuA;
|
||||
tabPKM[4] = Ludicolo;
|
||||
tabPKM[5] = Froakie;
|
||||
tabPKM[6] = Roselia;
|
||||
tabPKM[7] = Torterra;
|
||||
|
||||
for (int i = 0; i < tabPKM.length; i++) {
|
||||
System.out.println(tabPKM[i].toString());
|
||||
}
|
||||
|
||||
Infernape.attack(Ludicolo);
|
||||
Ludicolo.attack(Froakie);
|
||||
Froakie.attack(Infernape);
|
||||
Torterra.attack(Roselia);
|
||||
Roselia.attack(RaichuA);
|
||||
RaichuA.attack(Ninetales);
|
||||
Ninetales.attack(Roselia);
|
||||
Torterra.attack(Roselia);
|
||||
|
||||
System.out.println("=========================================================================");
|
||||
|
||||
for (int i = 0; i < tabPKM.length; i++) {
|
||||
System.out.println(tabPKM[i].toString());
|
||||
}
|
||||
|
||||
|
||||
System.out.println("Hello Pokeworld !");
|
||||
|
||||
}
|
||||
}
|
19
TD5/src/pokemon/Type.java
Executable file
19
TD5/src/pokemon/Type.java
Executable file
@ -0,0 +1,19 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user