Refonte du repo
This commit is contained in:
44
tests/TD7/MonnaieTest.java
Normal file
44
tests/TD7/MonnaieTest.java
Normal file
@ -0,0 +1,44 @@
|
||||
import monney.Monnaie;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
||||
public class MonnaieTest {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void avantTest() {
|
||||
System.out.println("----------Debut Test-------------");
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void apresTest() {
|
||||
System.out.println("-----------Fin Test--------------");
|
||||
}
|
||||
|
||||
@Test public void testEquals() {
|
||||
|
||||
Monnaie m12CHF = new Monnaie(12 , "CHF");
|
||||
Monnaie m14CHF = new Monnaie(14 , "CHF");
|
||||
Monnaie m15CHF = new Monnaie(14 , "USD");
|
||||
|
||||
assertTrue(!m12CHF.equals(null));
|
||||
assertEquals(m12CHF, m12CHF);
|
||||
assertEquals(m12CHF, new Monnaie(12, "CHF"));
|
||||
assertTrue(!m12CHF.equals(m14CHF));
|
||||
assertFalse(m12CHF.equals(m15CHF));
|
||||
|
||||
System.out.println(!m12CHF.equals(null));
|
||||
System.out.println(!m12CHF.equals(m14CHF));
|
||||
System.out.println(m12CHF.equals(m15CHF));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
75
tests/TD7/ip/IPTest.java
Normal file
75
tests/TD7/ip/IPTest.java
Normal file
@ -0,0 +1,75 @@
|
||||
package ip;
|
||||
|
||||
//import static org.junit.Assert.assertEquals;
|
||||
//import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//import org.junit.jupiter.api.BeforeEach;
|
||||
//import org.junit.jupiter.api.AfterEach;
|
||||
|
||||
class IPTest {
|
||||
|
||||
//@BeforeEach
|
||||
public void avantTest() {
|
||||
System.out.println("----------Debut Test-------------");
|
||||
}
|
||||
|
||||
//@AfterEach
|
||||
public void apresTest() {
|
||||
System.out.println("-----------Fin Test--------------");
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void testIPValide1() {
|
||||
String[] tabIp = new String[10];
|
||||
boolean[] tabRetatt = new boolean[tabIp.length];
|
||||
boolean[] tabRetour = new boolean[tabIp.length];
|
||||
|
||||
|
||||
tabIp[0] = "";
|
||||
tabIp[1] = "127.0.0.1";
|
||||
tabIp[2] = "127.231.1.1";
|
||||
tabIp[3] = "1.2.3.4";
|
||||
tabIp[4] = "12.2.3";
|
||||
tabIp[5] = "12.3.213.123.123";
|
||||
tabIp[6] = "1231.12.2.3";
|
||||
tabIp[7] = ".1.2.3";
|
||||
tabIp[8] = "1.2.3.";
|
||||
tabIp[9] = "1.2..3";
|
||||
|
||||
tabRetatt[0] = false;
|
||||
tabRetatt[1] = true;
|
||||
tabRetatt[2] = true;
|
||||
tabRetatt[3] = true;
|
||||
tabRetatt[4] = false;
|
||||
tabRetatt[5] = false;
|
||||
tabRetatt[6] = false;
|
||||
tabRetatt[7] = false;
|
||||
tabRetatt[8] = false;
|
||||
tabRetatt[9] = false;
|
||||
|
||||
for (int i = 0; i < tabRetatt.length; i++) {
|
||||
tabRetour[i] = IP.ipValide(tabIp[i]);
|
||||
}
|
||||
|
||||
System.out.println("attendu - retourne :");
|
||||
|
||||
for (int i = 0; i < tabRetatt.length; i++) {
|
||||
System.out.println(tabRetatt[i] + " - " + tabRetour[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Faire tableau ip
|
||||
puis faire tableau results attendus
|
||||
puis faire tableau booleens a remplir
|
||||
puis array assert.
|
||||
*/
|
||||
|
||||
}
|
46
tests/TD8/testJoueurs.java
Normal file
46
tests/TD8/testJoueurs.java
Normal file
@ -0,0 +1,46 @@
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import pokemon.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class testJoueurs {
|
||||
|
||||
Joueur j1 = new Joueur("JunkJumper");
|
||||
Joueur j2 = new Joueur("Rival");
|
||||
|
||||
PokemonELECTRIK p1 = new PokemonELECTRIK("Pikachu",0.5,5.,50,10,4,0,10);
|
||||
PokemonPLANTE p2 = new PokemonPLANTE("Herbizarre",0.5,5.,50,10);
|
||||
PokemonEAU p3 = new PokemonEAU("Carapuce",0.5,5.,50,10,0);
|
||||
PokemonFEU p4 = new PokemonFEU("Salameche",0.5,5.,50,10,4);
|
||||
|
||||
|
||||
|
||||
@AfterEach
|
||||
public void nettoyer() {
|
||||
j1 = null;
|
||||
j2 = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
{
|
||||
j1.attrapePokemon(p1);
|
||||
j2.attrapePokemon(p2);
|
||||
j2.attrapePokemon(p4);
|
||||
System.out.println("Debut du combat contre le rival :");
|
||||
System.out.println(p1.getNom()+" a "+p1.getPv()+" pv");
|
||||
System.out.println(p2.getNom()+" a "+p2.getPv()+" pv");
|
||||
do {
|
||||
|
||||
j1.attack(j2);
|
||||
j2.attack(j1);
|
||||
System.out.println(p1.getNom()+" a "+p1.getPv()+" pv");
|
||||
System.out.println(p2.getNom()+" a "+p2.getPv()+" pv");
|
||||
}while ((p1.getPv() > 0) && (p2.getPv() > 0));
|
||||
|
||||
}
|
||||
}
|
49
tests/TDPokemon/testPokemon.java
Normal file
49
tests/TDPokemon/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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user