TD pokemon
This commit is contained in:
parent
e5983242c6
commit
8e7f283cac
106
Pokemons/ListePokemon.txt
Normal file
106
Pokemons/ListePokemon.txt
Normal file
@ -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
|
49
Pokemons/Pokemon/Test/testPokemon.java
Normal file
49
Pokemons/Pokemon/Test/testPokemon.java
Normal file
@ -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());
|
||||||
|
}
|
||||||
|
}
|
BIN
Pokemons/Pokemon/bin/pokemons/CompareAlpha.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/CompareAlpha.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/CompareNiveau.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/CompareNiveau.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/IAttaque.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/IAttaque.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/Joueur.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/Joueur.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/Partie.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/Partie.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/PokeCentre.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/PokeCentre.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/Pokemon.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/Pokemon.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/PokemonEAU.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/PokemonEAU.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/PokemonELECTRIK.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/PokemonELECTRIK.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/PokemonFEU.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/PokemonFEU.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/PokemonPLANTE.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/PokemonPLANTE.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/pokemons/Type.class
Normal file
BIN
Pokemons/Pokemon/bin/pokemons/Type.class
Normal file
Binary file not shown.
BIN
Pokemons/Pokemon/bin/testPokemon.class
Normal file
BIN
Pokemons/Pokemon/bin/testPokemon.class
Normal file
Binary file not shown.
9
Pokemons/Pokemon/src/pokemons/CompareAlpha.java
Normal file
9
Pokemons/Pokemon/src/pokemons/CompareAlpha.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package pokemons;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class CompareAlpha implements Comparator<Joueur>{
|
||||||
|
public int compare(Joueur j, Joueur j2) {
|
||||||
|
return j.getNom().compareTo(j2.getNom());
|
||||||
|
}
|
||||||
|
}
|
10
Pokemons/Pokemon/src/pokemons/CompareNiveau.java
Normal file
10
Pokemons/Pokemon/src/pokemons/CompareNiveau.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package pokemons;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class CompareNiveau implements Comparator<Joueur> {
|
||||||
|
public int compare(Joueur j1, Joueur j2) {
|
||||||
|
if (j1.getNiveau() > j2.getNiveau())
|
||||||
|
return -1;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
}
|
5
Pokemons/Pokemon/src/pokemons/IAttaque.java
Normal file
5
Pokemons/Pokemon/src/pokemons/IAttaque.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package pokemons;
|
||||||
|
|
||||||
|
public interface IAttaque {
|
||||||
|
void attaque(Pokemon p);
|
||||||
|
}
|
79
Pokemons/Pokemon/src/pokemons/Joueur.java
Normal file
79
Pokemons/Pokemon/src/pokemons/Joueur.java
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
package pokemons;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class Joueur {
|
||||||
|
private String nom;
|
||||||
|
private int niveau;
|
||||||
|
private int nbPoints;
|
||||||
|
private ArrayList<Pokemon> collection;
|
||||||
|
|
||||||
|
//constructeur
|
||||||
|
public Joueur(String nom) {
|
||||||
|
this.nom = nom;
|
||||||
|
this.niveau = 1;
|
||||||
|
this.nbPoints = 0;
|
||||||
|
collection = new ArrayList<Pokemon>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Getters
|
||||||
|
public ArrayList<Pokemon> 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<collection.size(); i++) {
|
||||||
|
System.out.println(collection.get(i).affiche());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void gagnerNiveau() {
|
||||||
|
this.niveau ++;
|
||||||
|
System.out.println(this.nom + " gagne un niveau, niveau actuelle : " + this.getNiveau());
|
||||||
|
}
|
||||||
|
}
|
76
Pokemons/Pokemon/src/pokemons/Partie.java
Normal file
76
Pokemons/Pokemon/src/pokemons/Partie.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package pokemons;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class Partie {
|
||||||
|
//atributs
|
||||||
|
private ArrayList<Joueur> joueurs;
|
||||||
|
private ArrayList<Pokemon> pokemons;
|
||||||
|
|
||||||
|
//getters
|
||||||
|
public ArrayList<Pokemon> getPokemons() {
|
||||||
|
return pokemons;
|
||||||
|
}
|
||||||
|
|
||||||
|
//méthode
|
||||||
|
public void creerPokemons(String s) throws IOException, FileNotFoundException, InputMismatchException {
|
||||||
|
Scanner pokemon = new Scanner(new File (s));
|
||||||
|
ArrayList<Pokemon> pokemons= new ArrayList<Pokemon>();
|
||||||
|
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<Joueur> joueurs= new ArrayList<Joueur>();
|
||||||
|
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 "";
|
||||||
|
}
|
||||||
|
}
|
140
Pokemons/Pokemon/src/pokemons/PokeCentre.java
Normal file
140
Pokemons/Pokemon/src/pokemons/PokeCentre.java
Normal file
@ -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<p.getPokemons().size(); i++) {
|
||||||
|
if (p.getPokemons().get(i).getNom().equals(nom)) { //cherche le pokemon dans la liste
|
||||||
|
j1.attraperPokemon(p.getPokemons().get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Voulez-vous ajouter un autre Pokémon ? (oui/non)");
|
||||||
|
String reponse = sc.next();
|
||||||
|
if (reponse.equals("non")) {
|
||||||
|
j = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(j1.getNom() + " votre collection de Pokemon est complète !");
|
||||||
|
System.out.println(j1.toString());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
//pour j2
|
||||||
|
for (int j=0; j<6; j++) {
|
||||||
|
System.out.println(j2.getNom() + " entrez le nom d'un pokemon que vous souhaitez attraper");
|
||||||
|
String nom = sc.next();
|
||||||
|
for (int i=0; i<p.getPokemons().size(); i++) {
|
||||||
|
if (p.getPokemons().get(i).getNom().equals(nom)) { //cherche le pokemon dans la liste
|
||||||
|
j2.attraperPokemon(p.getPokemons().get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Voulez-vous ajouter un autre Pokémon ? (oui/non)");
|
||||||
|
String reponse = sc.next();
|
||||||
|
if (reponse.equals("non")) {
|
||||||
|
j = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(j2.getNom() + " votre collection de Pokemon est complète !");
|
||||||
|
System.out.println(j2.toString());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
//Combats !!!
|
||||||
|
System.out.println("Le combat peut commencé !!!");
|
||||||
|
Pokemon attaquant = null;
|
||||||
|
Pokemon deffenseur = null;
|
||||||
|
System.out.println(j1.getNom() + " quel pokémon voulez-vous mettre en jeux ? ");
|
||||||
|
String p1 = sc.next();
|
||||||
|
for (int i=0; i < j1.getCollection().size(); i++) {
|
||||||
|
if (j1.getCollection().get(i).getNom().equals(p1)) {
|
||||||
|
attaquant = j1.getCollection().get(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(j2.getNom() + " quel pokémon voulez-vous mettre en jeux ?");
|
||||||
|
String p2 = sc.next();
|
||||||
|
for (int j=0; j < j2.getCollection().size(); j++) {
|
||||||
|
if (j2.getCollection().get(j).getNom().equals(p2)) {
|
||||||
|
deffenseur = j2.getCollection().get(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (attaquant.getPv() > 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
70
Pokemons/Pokemon/src/pokemons/Pokemon.java
Normal file
70
Pokemons/Pokemon/src/pokemons/Pokemon.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package pokemons;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public abstract class Pokemon implements IAttaque, Comparable<Pokemon> {
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
}
|
39
Pokemons/Pokemon/src/pokemons/PokemonEAU.java
Normal file
39
Pokemons/Pokemon/src/pokemons/PokemonEAU.java
Normal file
@ -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());
|
||||||
|
}
|
||||||
|
}
|
49
Pokemons/Pokemon/src/pokemons/PokemonELECTRIK.java
Normal file
49
Pokemons/Pokemon/src/pokemons/PokemonELECTRIK.java
Normal file
@ -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());
|
||||||
|
}
|
||||||
|
}
|
42
Pokemons/Pokemon/src/pokemons/PokemonFEU.java
Normal file
42
Pokemons/Pokemon/src/pokemons/PokemonFEU.java
Normal file
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
32
Pokemons/Pokemon/src/pokemons/PokemonPLANTE.java
Normal file
32
Pokemons/Pokemon/src/pokemons/PokemonPLANTE.java
Normal file
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
13
Pokemons/Pokemon/src/pokemons/Type.java
Normal file
13
Pokemons/Pokemon/src/pokemons/Type.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user