diff --git a/Pokemons/ListePokemon.txt b/Pokemons/ListePokemon.txt new file mode 100644 index 0000000..8ec87b8 --- /dev/null +++ b/Pokemons/ListePokemon.txt @@ -0,0 +1,106 @@ +Bulbizarre Plante 0.7 6.9 294 62 +Herbizarre Plante 1.0 13.0 324 74 +Florizarre Plante 2.0 100.0 364 92 +Salameche Feu 0.6 8.5 282 65 4 +Reptincel Feu 1.1 19.0 320 76 4 +Dracaufeu Feu 1.7 90.5 360 94 4 +Carapuce Eau 0.5 9.0 292 61 4 +Carabaffe Eau 1.0 22.5 322 75 4 +Tortank Eau 1.8 85.5 362 93 4 +Pikachu Electrik 0.4 6.0 274 67 4 0 50 +Raichu Electrik 0.8 30.0 324 99 4 0 90 +Goupix Feu 0.6 9.9 280 55 4 +Feunard Feu 1.1 19.9 350 86 4 +Mystherbe Plante 0.5 5.4 294 63 +Ortide Plante 0.8 8.6 324 76 +Rafflesia Plante 1.2 18.6 354 90 +Paras Plante 0.3 5.4 274 81 +Parasect Plante 1.0 29.5 324 103 +Psykokwak Eau 0.8 19.6 304 65 4 +Akwakwak Eau 1.7 76.6 364 92 4 +Caninos Feu 0.7 19.0 314 81 4 +Arcanin Feu 1.9 155.0 384 117 4 +Ptitard Eau 0.6 12.4 284 63 3 +Tetarte Eau 1.0 20.0 334 76 4 +Tartard Eau 1.3 54.0 384 94 4 +Chetiflor Plante 0.7 4.0 304 85 +Boustiflor Plante 1.0 6.4 334 99 +Empiflor Plante 1.7 15.5 364 112 +Tentacool Eau 0.9 45.5 284 54 2 +Tentacruel Eau 1.6 55.0 364 81 6 +Ponyta Feu 1.0 30.0 304 94 4 +Galopa Feu 1.7 95.0 334 108 4 +Ramoloss Eau 1.2 36.0 384 76 5 +Flagadoss Eau 1.6 78.5 394 85 5 +Magneti Electrik 0.3 6.0 254 49 0 2 95 +Magneton Electrik 1.0 60.0 304 72 0 6 120 +Otaria Eau 1.1 90.0 334 58 3 +Lamantine Eau 1.7 120.0 384 81 3 +Kokiyas Eau 0.3 4.0 264 76 0 +Crustabri Eau 1.5 132.5 304 103 0 +Kraby Eau 0.4 6.5 264 112 2 +Krabboss Eau 1.3 60.0 314 135 2 +Voltorbe Electrik 0.5 10.4 284 45 0 1 55 +Electrode Electrik 1.2 66.6 324 63 0 1 80 +Noeunoeuf Plante 0.4 2.5 324 54 +Noadkoko Plante 2.0 120.0 394 103 +Saquedeneu Plante 1.0 35.0 334 67 +Hypotrempe Eau 0.4 8.0 264 54 1 +Hypocean Eau 1.2 25.0 314 76 1 +Poissirene Eau 0.6 15.0 294 78 3 +Poissoroy Eau 1.3 39.0 364 101 3 +Stari Eau 0.8 34.5 264 58 1 +Staross Eau 1.1 80.0 324 85 1 +Elektek Electrik 1.1 30.0 334 93 4 0 95 +Magmar Feu 1.3 44.5 334 103 4 +Magicarpe Eau 0.9 10.0 244 27 3 +Leviator Eau 6.5 235.0 394 130 1 +Lokhlass Eau 2.5 220.0 464 94 2 +Aquali Eau 1.0 29.0 464 76 7 +Voltali Electrik 0.8 24.5 334 76 4 0 110 +Pyroli Feu 0.9 25.9 334 135 4 +Amonita Eau 0.4 7.5 274 54 2 +Amonistar Eau 1.0 35.0 344 72 4 +Kabuto Eau 0.5 11.5 264 90 1 +Kabutops Eau 1.3 40.5 324 121 2 +Electhor Electrik 1.6 52.6 384 99 2 2 125 +Sulfura Feu 2.0 60.0 384 108 2 +Germignon Plante 0.9 6.4 294 62 +Macronium Plante 1.2 15.8 324 74 +Meganium Plante 1.8 100.5 364 92 +Hericendre Feu 0.5 7.9 282 65 4 +Feurisson Feu 0.9 19.0 320 76 4 +Typhlosion Feu 1.7 79.5 360 94 4 +Kaiminus Eau 0.6 9.5 304 76 4 +Crocrodil Eau 1.1 25.0 334 90 4 +Aligatueur Eau 2.3 88.8 374 112 4 +Loupio Electrik 0.5 12.0 354 52 2 2 56 +Lanturn Electrik 1.2 22.5 454 70 0 2 76 +Pichu Electrik 0.3 2.0 244 54 4 0 35 +Wattouat Electrik 0.6 7.8 314 54 4 0 65 +Lainergie Electrik 0.8 13.3 344 67 4 0 80 +Pharamp Electrik 1.4 61.5 384 85 4 0 115 +Joliflor Plante 0.4 5.8 354 90 +Marill Eau 0.4 8.5 344 36 4 +Azumarill Eau 0.8 28.5 404 63 6 +Tarpaud Eau 1.1 33.9 383 85 4 +Granivol Plante 0.4 0.5 274 49 +Floravol Plante 0.6 1.0 314 58 +Cotovol Plante 0.8 3.0 354 67 +Tournegrin Plante 0.3 1.8 264 45 +Heliatronc Plante 0.8 8.5 354 85 +Axoloto Eau 0.4 8.5 314 58 2 +Maraiste Eau 1.4 75.0 394 94 4 +Roigada Eau 2.0 79.5 394 85 3 +Qwilfish Eau 0.5 3.9 334 103 1 +Limagma Feu 0.7 35.0 284 54 2 +Volcaropod Feu 0.8 55.0 304 63 2 +Corayon Eau 0.6 5.0 314 67 0 +Remoraid Eau 0.6 12.0 274 76 2 +Octillery Eau 0.9 28.5 354 112 2 +Demanta Eau 2.1 220.0 334 54 2 +Malosse Feu 0.6 10.8 294 72 4 +Demolosse Feu 1.4 35.0 354 99 4 +Hyporoi Eau 1.8 152.0 354 103 1 +Elekid Electrik 0.6 23.5 294 75 4 0 65 +Magby Feu 0.7 21.4 294 85 4 \ No newline at end of file diff --git a/Pokemons/Pokemon/Test/testPokemon.java b/Pokemons/Pokemon/Test/testPokemon.java new file mode 100644 index 0000000..6026f55 --- /dev/null +++ b/Pokemons/Pokemon/Test/testPokemon.java @@ -0,0 +1,49 @@ +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.*; + +import pokemons.Joueur; +import pokemons.PokemonEAU; +import pokemons.PokemonELECTRIK; +import pokemons.PokemonFEU; +import pokemons.PokemonPLANTE; + +class testPokemon { + //test Pokemons + PokemonPLANTE celebi = new PokemonPLANTE("Celebi", 0.6, 5.0, 100, 50); + PokemonFEU hooh = new PokemonFEU("Ho-Oh", 3.8, 199.0, 106, 52, 2); + PokemonEAU kyogre = new PokemonEAU("Kyogre", 4.5, 352.0, 100, 30, 7); + PokemonELECTRIK electhor = new PokemonELECTRIK("Electhor", 1.6, 52.6, 90, 15, 2, 2, 90); + + @Test + void testAffiche() { + assertEquals("Pokemon Celebi de type PLANTE (5.0 kg, 0.6 m, 100 pts de vie, 50 force de combat)" + , celebi.affiche()); + assertEquals("Pokemon Ho-Oh de type FEU (199.0 kg, 3.8 m, 106 pts de vie, 52 force de combat, 199.0 kg, 3.8 m, 106 pts de vie, 52 force de combat, 2 pattes)", + hooh.affiche()); + assertEquals("Pokemon Kyogre de type EAU (352.0 kg, 4.5 m, 100 pts de vie, 30 force de combat, 7 nageoires)", + kyogre.affiche()); + assertEquals("Pokemon Electhor de type ELECTRIK (52.6 kg, 1.6 m, 90 pts de vie, 15 force de combat, 2 pattes, 2 ailes, 90.0 mA)", + electhor.affiche()); + } + + @Test + void testCalulerVitesse() { + assertEquals(3.3333333333333335 , celebi.calculerVitesse()); + assertEquals(11.94 , hooh.calculerVitesse()); + assertEquals(98.56 , kyogre.calculerVitesse()); + assertEquals(18.0, electhor.calculerVitesse()); + } + + @Test + void testAttaque() { + celebi.attaque(hooh); + assertEquals(81, hooh.getPv()); + hooh.attaque(celebi); + assertEquals(0, celebi.getPv()); + kyogre.attaque(electhor); + assertEquals(60, electhor.getPv()); + electhor.attaque(kyogre); + assertEquals(70, kyogre.getPv()); + } +} diff --git a/Pokemons/Pokemon/bin/pokemons/CompareAlpha.class b/Pokemons/Pokemon/bin/pokemons/CompareAlpha.class new file mode 100644 index 0000000..fa9e350 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/CompareAlpha.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/CompareNiveau.class b/Pokemons/Pokemon/bin/pokemons/CompareNiveau.class new file mode 100644 index 0000000..6baa8b2 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/CompareNiveau.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/IAttaque.class b/Pokemons/Pokemon/bin/pokemons/IAttaque.class new file mode 100644 index 0000000..c3a0085 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/IAttaque.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/Joueur.class b/Pokemons/Pokemon/bin/pokemons/Joueur.class new file mode 100644 index 0000000..b36c995 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/Joueur.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/Partie.class b/Pokemons/Pokemon/bin/pokemons/Partie.class new file mode 100644 index 0000000..943bc55 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/Partie.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/PokeCentre.class b/Pokemons/Pokemon/bin/pokemons/PokeCentre.class new file mode 100644 index 0000000..68f47a7 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/PokeCentre.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/Pokemon.class b/Pokemons/Pokemon/bin/pokemons/Pokemon.class new file mode 100644 index 0000000..86c18b0 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/Pokemon.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/PokemonEAU.class b/Pokemons/Pokemon/bin/pokemons/PokemonEAU.class new file mode 100644 index 0000000..9df7c58 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/PokemonEAU.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/PokemonELECTRIK.class b/Pokemons/Pokemon/bin/pokemons/PokemonELECTRIK.class new file mode 100644 index 0000000..c0e0b13 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/PokemonELECTRIK.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/PokemonFEU.class b/Pokemons/Pokemon/bin/pokemons/PokemonFEU.class new file mode 100644 index 0000000..3d06fc4 Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/PokemonFEU.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/PokemonPLANTE.class b/Pokemons/Pokemon/bin/pokemons/PokemonPLANTE.class new file mode 100644 index 0000000..181b95f Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/PokemonPLANTE.class differ diff --git a/Pokemons/Pokemon/bin/pokemons/Type.class b/Pokemons/Pokemon/bin/pokemons/Type.class new file mode 100644 index 0000000..ade42ff Binary files /dev/null and b/Pokemons/Pokemon/bin/pokemons/Type.class differ diff --git a/Pokemons/Pokemon/bin/testPokemon.class b/Pokemons/Pokemon/bin/testPokemon.class new file mode 100644 index 0000000..d246323 Binary files /dev/null and b/Pokemons/Pokemon/bin/testPokemon.class differ diff --git a/Pokemons/Pokemon/src/pokemons/CompareAlpha.java b/Pokemons/Pokemon/src/pokemons/CompareAlpha.java new file mode 100644 index 0000000..3e29c25 --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/CompareAlpha.java @@ -0,0 +1,9 @@ +package pokemons; + +import java.util.Comparator; + +public class CompareAlpha implements Comparator{ + public int compare(Joueur j, Joueur j2) { + return j.getNom().compareTo(j2.getNom()); + } +} diff --git a/Pokemons/Pokemon/src/pokemons/CompareNiveau.java b/Pokemons/Pokemon/src/pokemons/CompareNiveau.java new file mode 100644 index 0000000..dfbcd13 --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/CompareNiveau.java @@ -0,0 +1,10 @@ +package pokemons; +import java.util.Comparator; + +public class CompareNiveau implements Comparator { + public int compare(Joueur j1, Joueur j2) { + if (j1.getNiveau() > j2.getNiveau()) + return -1; + else return 0; + } +} diff --git a/Pokemons/Pokemon/src/pokemons/IAttaque.java b/Pokemons/Pokemon/src/pokemons/IAttaque.java new file mode 100644 index 0000000..aecb747 --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/IAttaque.java @@ -0,0 +1,5 @@ +package pokemons; + +public interface IAttaque { + void attaque(Pokemon p); +} diff --git a/Pokemons/Pokemon/src/pokemons/Joueur.java b/Pokemons/Pokemon/src/pokemons/Joueur.java new file mode 100644 index 0000000..6e46962 --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/Joueur.java @@ -0,0 +1,79 @@ +package pokemons; +import java.util.*; + +public class Joueur { + private String nom; + private int niveau; + private int nbPoints; + private ArrayList collection; + + //constructeur + public Joueur(String nom) { + this.nom = nom; + this.niveau = 1; + this.nbPoints = 0; + collection = new ArrayList(); + } + + //Getters + public ArrayList getCollection() { + return collection; + } + + public String getNom() { + return nom; + } + + public int getNiveau() { + return niveau; + } + + public int getnbPoints() { + return nbPoints; + } + + //méthodes + public void attraperPokemon(Pokemon p) { + this.collection.add(p); + System.out.println(this.nom + " ŕ attraper " + p.getNom()); + } + + public void transfererPokemon(Pokemon p) { + this.collection.remove(p); + System.out.println(this.nom + " ŕ transférer " + p.getNom()); + } + + public double vitesseMoyenne() { + double resultat = 0; + for (Pokemon p : collection) + resultat += p.calculerVitesse(); + return resultat / collection.size(); + } + + public double vitesseMoyenneTYPE(String t) { + double resultat = 0; + int compteur = 0; + for (Pokemon p : collection) { + if (p.getType().getDescription().equals(t)) { + resultat += p.calculerVitesse(); + compteur++; + } + } + return resultat / compteur; + } + + public String toString() { + System.out.println("Joueur " + this.nom + ", niveau " + this.niveau + + "\rNombre de points : " + this.nbPoints + + "\rPossčde : "); + for (int i=0; i joueurs; + private ArrayList pokemons; + + //getters + public ArrayList getPokemons() { + return pokemons; + } + + //méthode + public void creerPokemons(String s) throws IOException, FileNotFoundException, InputMismatchException { + Scanner pokemon = new Scanner(new File (s)); + ArrayList pokemons= new ArrayList(); + while (pokemon.hasNextLine()) + { + String str = pokemon.nextLine(); + Scanner scn = new Scanner(str); + scn.useDelimiter("\\s* \\s*"); + String nom = scn.next(); + String type = scn.next(); + double taille = Double.parseDouble(scn.next()); + double poids = Double.parseDouble(scn.next()); + int pv = Integer.parseInt(scn.next()); + int pc = Integer.parseInt(scn.next()); + + switch (type) { + case "Eau" : + int nbNageoires = Integer.parseInt(scn.next()); + PokemonEAU p1 = new PokemonEAU(nom, taille, poids, pv, pc, nbNageoires) ; + pokemons.add(p1); + break; + case "Plante" : + PokemonPLANTE p2 = new PokemonPLANTE(nom, taille, poids, pv, pc); + pokemons.add(p2); + break; + case "Feu" : + int nbPattes = Integer.parseInt(scn.next()); + PokemonFEU p3 = new PokemonFEU(nom, taille, poids, pv, pc, nbPattes); + pokemons.add(p3); + break; + case "Electrik" : + int nb_Pattes = Integer.parseInt(scn.next()); + int nbAiles = Integer.parseInt(scn.next()); + int intensite = Integer.parseInt(scn.next()); + PokemonELECTRIK p4 = new PokemonELECTRIK(nom, taille, poids, pv, pc, nb_Pattes, nbAiles, intensite); + pokemons.add(p4); + break; + } + scn.close(); + } + pokemon.close(); + this.pokemons = pokemons; + + } + + public void ajouterJoueur(Joueur j) { + ArrayList joueurs= new ArrayList(); + joueurs.add(j); + this.joueurs = joueurs; + System.out.println(joueurs.toString()); + } + + public String toString() { + System.out.println(); + System.out.println("Et voici la liste des pokemons disponibles : "); + for (int j=0; j< pokemons.size(); j++) { + System.out.println(pokemons.get(j).affiche()); + } + return ""; + } +} diff --git a/Pokemons/Pokemon/src/pokemons/PokeCentre.java b/Pokemons/Pokemon/src/pokemons/PokeCentre.java new file mode 100644 index 0000000..856e73e --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/PokeCentre.java @@ -0,0 +1,140 @@ +package pokemons; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.*; + +public class PokeCentre { + + public static void main(String[] args) { + + try { + //creation Partie + Partie p = new Partie(); + p.creerPokemons("../ListePokemon.txt"); + + Scanner sc = new Scanner(System.in); + System.out.println("Entrez nom Joueur 1"); + String nomj1 = sc.next(); + System.out.println("Entrez nom Joueur 2"); + String nomj2 = sc.next(); + Joueur j1 = new Joueur(nomj1); + p.ajouterJoueur(j1); + Joueur j2 = new Joueur(nomj2); + p.ajouterJoueur(j2); + + System.out.println(p.toString()); + + //Choix des pokémons + //pour j1 + for (int j=0; j<5; j++) { + System.out.println(j1.getNom() + " entrez le nom d'un pokemon que vous souhaitez attraper"); + String nom = sc.next(); + for (int i=0; i 0 && deffenseur.getPv() > 0) { + if (attaquant.calculerVitesse() > deffenseur.calculerVitesse()) { + attaquant.attaque(deffenseur); + deffenseur.attaque(attaquant); + }else { + deffenseur.attaque(attaquant); + attaquant.attaque(deffenseur); + } + + if (attaquant.getPv() <= 0) { + System.out.println(); + System.out.println(attaquant.getNom() + " est vaincu"); + System.out.println(); + j1.getCollection().remove(attaquant); + if (j1.getCollection().size() > 0) { + System.out.println(j1.getNom() + " quel pokémon voulez-vous remettre en jeux ?"); + String pokemon = sc.next(); + for (int i=0; i < j1.getCollection().size(); i++) { + if (j1.getCollection().get(i).getNom().equals(pokemon)) { + attaquant = j1.getCollection().get(i); + } + } + } + } + if (deffenseur.getPv() <= 0) { + System.out.println(); + System.out.println(deffenseur.getNom() + " est vaincu"); + System.out.println(); + j2.getCollection().remove(deffenseur); + if (j2.getCollection().size() > 0) { + System.out.println(j2.getNom() + " quel pokémon voulez-vous remettre en jeux ?"); + String pokemon = sc.next(); + for (int i=0; i < j2.getCollection().size(); i++) { + if (j2.getCollection().get(i).getNom().equals(pokemon)) { + deffenseur = j2.getCollection().get(i); + } + } + } + } + } + + System.out.println("Fin de partie !"); + if (j1.getCollection().size() > 0) { + System.out.println(j1.getNom() + " est vainceur !"); + }else System.out.println(j2.getNom() + " est vainceur !"); + + sc.close(); + + }catch (FileNotFoundException e) { + e.printStackTrace(); + }catch (IOException e) { + e.printStackTrace(); + } + + } +} diff --git a/Pokemons/Pokemon/src/pokemons/Pokemon.java b/Pokemons/Pokemon/src/pokemons/Pokemon.java new file mode 100644 index 0000000..44f0160 --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/Pokemon.java @@ -0,0 +1,70 @@ +package pokemons; +import java.util.*; + +public abstract class Pokemon implements IAttaque, Comparable { + //attributs + private String nom; + private double taille; // en m + private double poids; // en kg + private int pv; + private int pc; + Type type; + + //constructeurs + public Pokemon(String n, double t, double p, int v, int c) { + nom = n; + taille = t; + poids = p; + pv = v; + pc = c; + } + + //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; + } + + //Méthodes + public String toString() { + return "Pokemon "+nom + +" de type "+ type.getDescription() + +" ("+poids+" kg, " + +taille+" m, " + +pv+" pts de vie, " + +pc+" force de combat"; + } + + public void changePv(int modif) { + pv = Math.max(0, pv-modif); + System.out.println(this.nom + " perd " + modif + " pv"); + } + + public abstract void attaque(Pokemon p); + + public abstract double calculerVitesse(); + + public abstract String affiche(); + + public int compareTo(Pokemon p) + { + int n = this.getType().getDescription().compareTo(p.getType().getDescription()); + if (n == 0) + return this.getPv() - p.getPv(); + else return n; + } +} diff --git a/Pokemons/Pokemon/src/pokemons/PokemonEAU.java b/Pokemons/Pokemon/src/pokemons/PokemonEAU.java new file mode 100644 index 0000000..9fba7ff --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/PokemonEAU.java @@ -0,0 +1,39 @@ +package pokemons; + +public class PokemonEAU extends Pokemon { + //attribut + private int nb_nageoires; + + //Constructeurs + public PokemonEAU(String n, double t, double p, int v, int c, int g) { + super (n, t, p, v, c); + nb_nageoires = g; + type = Type.EAU; + } + + //Getters + public int getNb_nageoires() { + return nb_nageoires; + } + + //méthodes + @Override + public double calculerVitesse() { + return (super.getPoids()*nb_nageoires)/25.0; + } + + @Override + public String affiche() { + return this.toString() + ", " + nb_nageoires + " nageoires)"; + } + + @Override + public void attaque(Pokemon p) { + System.out.println(this.getNom() + " attaque " + p.getNom()); + if (p.getType() == Type.FEU) + p.changePv(super.getPc()*2); + else if (p.getType() == Type.EAU|| p.getType() == Type.PLANTE) + p.changePv( (int) Math.round(super.getPc()*0.5)); + else p.changePv(super.getPc()); + } +} diff --git a/Pokemons/Pokemon/src/pokemons/PokemonELECTRIK.java b/Pokemons/Pokemon/src/pokemons/PokemonELECTRIK.java new file mode 100644 index 0000000..5dfa61b --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/PokemonELECTRIK.java @@ -0,0 +1,49 @@ +package pokemons; + +public class PokemonELECTRIK extends Pokemon { + //attributs + private int nb_pattes; + private int nb_ailes; + private double intensite; + + //constructeur + public PokemonELECTRIK(String n, double t, double p, int v, int c, int g, int a, double i) { + super (n, t, p, v, c); + nb_pattes = g; + nb_ailes = a; + intensite = i; + type = Type.ELECTRIK; + } + + //getters + public int getPattes() { + return nb_pattes; + } + public int getAiles() { + return nb_ailes; + } + public double getIntensite() { + return intensite; + } + + //méthodes + @Override + public double calculerVitesse() { + return (nb_ailes+nb_pattes) * intensite * 0.05; + } + + @Override + public String affiche() { + return this.toString()+ ", " +nb_pattes+" pattes, "+nb_ailes+" ailes, "+intensite+" mA)"; + } + + @Override + public void attaque(Pokemon p) { + System.out.println(this.getNom() + " attaque " + p.getNom()); + if (p.getType() == Type.EAU) + p.changePv(super.getPc()*2); + else if (p.getType() == Type.ELECTRIK || p.getType() == Type.PLANTE) + p.changePv( (int) Math.round(super.getPc()*0.5)); + else p.changePv(super.getPc()); + } +} diff --git a/Pokemons/Pokemon/src/pokemons/PokemonFEU.java b/Pokemons/Pokemon/src/pokemons/PokemonFEU.java new file mode 100644 index 0000000..a4a35cd --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/PokemonFEU.java @@ -0,0 +1,42 @@ +package pokemons; + +public class PokemonFEU extends Pokemon { + //attributs + private int nb_pattes; + + //constructeurs + public PokemonFEU(String n, double t, double p, int v, int c, int g) { + super (n, t, p, v, c); + nb_pattes = g; + type = Type.FEU; + } + + //getters + + public int getPattes() { + return nb_pattes; + } + + //méthodes + @Override + public double calculerVitesse() { + return this.getPoids()*nb_pattes* 0.03; + } + + @Override + public String affiche() { + return this.toString() + ", " +super.getPoids()+" kg, "+super.getTaille()+" m, "+super.getPv()+" pts de vie, "+super.getPc()+" force de combat, "+nb_pattes+" pattes)"; + } + + @Override + public void attaque(Pokemon p) { + System.out.println(this.getNom() + " attaque " + p.getNom()); + if (p.getType() == Type.PLANTE) + p.changePv(super.getPc()*2); + else if (p.getType() == Type.EAU || p.getType() == Type.ELECTRIK) + p.changePv( (int) Math.round(super.getPc()*0.5)); + else p.changePv(super.getPc()); + } + + +} diff --git a/Pokemons/Pokemon/src/pokemons/PokemonPLANTE.java b/Pokemons/Pokemon/src/pokemons/PokemonPLANTE.java new file mode 100644 index 0000000..750969b --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/PokemonPLANTE.java @@ -0,0 +1,32 @@ +package pokemons; + +public class PokemonPLANTE extends Pokemon { + + //Constructeur + public PokemonPLANTE(String n, double t, double p, int v, int c) { + super (n, t, p, v, c); + type = Type.PLANTE; + } + + //méthodes + @Override + public double calculerVitesse() { + return 10.0 / (this.getPoids()*this.getTaille()); + } + + @Override + public String affiche() { + return this.toString() + ")"; + } + + @Override + public void attaque(Pokemon p) { + System.out.println(this.getNom() + " attaque " + p.getNom()); + if (p.getType() == Type.ELECTRIK) + p.changePv(super.getPc()*2); + else if (p.getType() == Type.FEU || p.getType() == Type.PLANTE) + p.changePv( (int) Math.round(super.getPc()*0.5)); + else p.changePv(super.getPc()); + } + +} diff --git a/Pokemons/Pokemon/src/pokemons/Type.java b/Pokemons/Pokemon/src/pokemons/Type.java new file mode 100644 index 0000000..4b3134b --- /dev/null +++ b/Pokemons/Pokemon/src/pokemons/Type.java @@ -0,0 +1,13 @@ +package pokemons; + +enum Type { + EAU ("EAU"), + ELECTRIK ("ELECTRIK"), + FEU ("FEU"), + PLANTE ("PLANTE"); + Type(String s){description = s;} + private String description; + public String getDescription() { + return description; + } +}