diff --git a/tp1/lib/hamcrest-core-1.3.jar b/tp1/lib/hamcrest-core-1.3.jar new file mode 100644 index 0000000..9d5fe16 Binary files /dev/null and b/tp1/lib/hamcrest-core-1.3.jar differ diff --git a/tp1/lib/junit-4.12.jar b/tp1/lib/junit-4.12.jar new file mode 100644 index 0000000..3a7fc26 Binary files /dev/null and b/tp1/lib/junit-4.12.jar differ diff --git a/tp4_banque/banque/Banque$CompteInexistanException.class b/tp4_banque/banque/Banque$CompteInexistanException.class new file mode 100644 index 0000000..60962f9 Binary files /dev/null and b/tp4_banque/banque/Banque$CompteInexistanException.class differ diff --git a/tp4_banque/banque/Banque.class b/tp4_banque/banque/Banque.class new file mode 100644 index 0000000..50eabfe Binary files /dev/null and b/tp4_banque/banque/Banque.class differ diff --git a/tp4_banque/banque/Banque.java b/tp4_banque/banque/Banque.java new file mode 100644 index 0000000..07fb765 --- /dev/null +++ b/tp4_banque/banque/Banque.java @@ -0,0 +1,113 @@ +import java.util.*; + +public class Banque { + List comptes; + int nbComptes =0; + + public Banque(){ + comptes = new ArrayList(); + this.nbComptes = 0 ; + } + + public int ouvrirCompte(){ + comptes.add(new Compte()); + nbComptes ++; + return this.nbComptes; + } + + public int ouvrirCompteEpargne(double credit, double interet){ + comptes.add(new CompteEpargne(credit,interet)); + nbComptes ++; + return nbComptes; + } + + public Compte getCompte(int i) throws CompteInexistantException{ + if(i > nbComptes && i>0){ + throw new CompteInexistantException(); + + }else{ + return this.comptes.get(i-1); + } + } + + public void crediter(int i, double x)throws CompteInexistantException{ + if(i > nbComptes && i>0){ + throw new CompteInexistantException(); + }else{ + getCompte(i).crediter(x); + } + } + + public void debiter(int i, double x)throws CompteInexistantException{ + if(i > nbComptes && i>0){ + throw new CompteInexistantException(); + }else{ + getCompte(i).debiter(x); + } + } + + public double totalSolde(){ + double totalSolde = 0; + if(!comptes.isEmpty()){ + for(Compte compte : comptes){ + totalSolde += compte.solde(); + }} + return totalSolde; + } + + public String etat(int i) throws CompteInexistantException{ + if(i > nbComptes){ + throw new CompteInexistantException(); + }else{ + return getCompte(i).toString(); + } + } + + public void etat() { + System.out.println("Vos comptes: "); + int indice=0; + for(Compte compte : comptes){ + indice++; + System.out.println("Pour le compte: " + indice + " et "+ compte.toString()); + } + } + + public void virement(int numSrc, int numDest, double x)throws CompteInexistantException{ + if((numSrc > nbComptes)||(numDest > nbComptes)){ + throw new CompteInexistantException(); + }else{ + getCompte(numSrc).virerVers(x, getCompte(numDest)); + } + } + + public double interets(int i)throws CompteInexistantException{ + if(i > nbComptes){ + throw new CompteInexistantException(); + }else{ + try{ + CompteEpargne ce = (CompteEpargne)getCompte(i); + return ce.interets(); + } catch (ClassCastException e){ + + } + + + } + return 0; + + } + + public void echeance(int i)throws CompteInexistantException{ + if(i > nbComptes){ + throw new CompteInexistantException(); + }else{ + try{ + CompteEpargne ce = (CompteEpargne)getCompte(i); + ce.echeance(); + } catch (ClassCastException e){ + } + } + } + + +} diff --git a/tp4_banque/banque/Compte.class b/tp4_banque/banque/Compte.class new file mode 100644 index 0000000..6063080 Binary files /dev/null and b/tp4_banque/banque/Compte.class differ diff --git a/tp4_banque/banque/Compte.java b/tp4_banque/banque/Compte.java new file mode 100644 index 0000000..4092aca --- /dev/null +++ b/tp4_banque/banque/Compte.java @@ -0,0 +1,52 @@ + + +public class Compte { + double credit = 0; + double debit = 0; + + public double getCredit(){ + return this.credit; + } + + public double getDebit(){ + return this.debit; + } + + public void setCredit(double x){ + this.credit = x; + } + + public void setDebit(double x){ + this.debit = x; + } + + public Compte(){ + + } + + public Compte(double val){ + setCredit(val); + } + + public void crediter(double val){ + setCredit(getCredit()+val); + } + + public void debiter(double val){ + setDebit(getDebit()+val); + } + + public double solde(){ + return (getCredit()-getDebit()); + } + + public String toString(){ + return "Le solde actuel est de "+solde()+" ("+getCredit()+" - "+getDebit()+")"; + } + + public void virerVers (double x, Compte dest){ + dest.crediter(x); + this.debiter(x); + } + +} diff --git a/tp4_banque/banque/CompteEpargne.class b/tp4_banque/banque/CompteEpargne.class new file mode 100644 index 0000000..4defcce Binary files /dev/null and b/tp4_banque/banque/CompteEpargne.class differ diff --git a/tp4_banque/banque/CompteEpargne.java b/tp4_banque/banque/CompteEpargne.java new file mode 100644 index 0000000..1aa4134 --- /dev/null +++ b/tp4_banque/banque/CompteEpargne.java @@ -0,0 +1,49 @@ + +public class CompteEpargne extends Compte { + + private double interet; + + public double getInteret(){ + return this.interet; + } + + public void setInteret(double x){ + this.interet = x; + } + + public double interets(){ + return (getCredit()-getDebit())*getInteret(); + } + + public void echeance(){ + crediter(interets()); + } + + public void debiter(double val){ + if((getCredit()-val)>0){ + setDebit(getDebit()+val); + + }else { + System.out.println("Compte non débitable"); + } + } + + public CompteEpargne(double creditInit, double interet){ + super(creditInit); + setInteret(interet); + } + + public CompteEpargne(){ + super(); + setInteret(0.1); + } + + public String etat(){ + return super.toString()+" Interets du mois: "+ interets(); + } + + public String toString(){ + return super.toString()+" Interets du mois: "+ interets(); + } + +} diff --git a/tp4_banque/banque/CompteInexistanException.class b/tp4_banque/banque/CompteInexistanException.class new file mode 100644 index 0000000..fe0c51e Binary files /dev/null and b/tp4_banque/banque/CompteInexistanException.class differ diff --git a/tp4_banque/banque/CompteInexistantException.class b/tp4_banque/banque/CompteInexistantException.class new file mode 100644 index 0000000..63e88fa Binary files /dev/null and b/tp4_banque/banque/CompteInexistantException.class differ diff --git a/tp4_banque/banque/CompteInexistantException.java b/tp4_banque/banque/CompteInexistantException.java new file mode 100644 index 0000000..53e8939 --- /dev/null +++ b/tp4_banque/banque/CompteInexistantException.java @@ -0,0 +1,5 @@ +public class CompteInexistantException extends Exception{ + public CompteInexistantException(){ + System.out.println("Compte inexistant"); + } + } diff --git a/tp4_banque/banque/Guichet.class b/tp4_banque/banque/Guichet.class new file mode 100644 index 0000000..11dd4dc Binary files /dev/null and b/tp4_banque/banque/Guichet.class differ diff --git a/tp4_banque/banque/Guichet.java b/tp4_banque/banque/Guichet.java new file mode 100644 index 0000000..d42815c --- /dev/null +++ b/tp4_banque/banque/Guichet.java @@ -0,0 +1,136 @@ +import java.util.Scanner; + +public class Guichet { + static Scanner in = new Scanner(System.in); + // creation de la banque : + static Banque bank = new Banque(); + static int nombreEssai ; + + public static void main (String[] args) { + nombreEssai=0; + int choix=0; + do { + menu(); + System.out.print("votre choix? "); + choix = in.nextInt(); + switch (choix) { + case 1 : // etat des comptes + bank.etat(); + break; + case 2 : // creer un nouveau compte + menuNouveauCompte(); + break; + case 3: // crediter un compte + menuCrediter(); + break; + case 4: // debiter un compte + menuDebiter(); + break; + case 5: // effectuer un virement + menuVirement(); + break; + case 6: // effectuer un virement + menuNouveauCompteEpargne(); + break; + case 7: + menuInterets(); + break; + case 8: // effectuer un virement + menuEcheance(); + break; + case 0: // quitter + } + } while (choix!=0); + System.out.println("au revoir"); + } + + static void menu() { + System.out.println("\n1: etat des comptes\n2: creer un nouveau compte\n3: crediter un compte\n4: debiter un compte\n5: effectuer un virement\n6: creer un nouveau compte epargne\n7: interets\n8: echeance\n0: quitter"); + } + + static void menuNouveauCompte() { + int num; + num=bank.ouvrirCompte(); + System.out.println("numero= "+num); + } + + static void menuNouveauCompteEpargne() { + double num; + System.out.print("\ncredit? "); + num=in.nextDouble(); + System.out.print("interet? "); + num=bank.ouvrirCompteEpargne(num, in.nextDouble()); + System.out.println("numero= "+num); + } + + static void menuCrediter(){ +try{ + int num; + System.out.print("\nnumero du compte? "); + num=in.nextInt(); + System.out.print("somme? "); + bank.crediter(num, in.nextDouble()); +}catch (CompteInexistantException e){ +nombreEssai++; +System.out.println("Nombre essais invalides: "+ nombreEssai); +} + + } + + static void menuDebiter() { + try{ + int num; + System.out.print("\nnumero du compte? "); + num=in.nextInt(); + System.out.print("somme? "); + bank.debiter(num, in.nextDouble()); + }catch (CompteInexistantException e){ + nombreEssai++; +System.out.println("Nombre essais invalides: "+ nombreEssai); +} + + } + + static void menuVirement() { + try{ + int from, to; + System.out.print("\ncompte a debiter? "); + from=in.nextInt(); + System.out.print("compte a crediter? "); + to=in.nextInt(); + System.out.print("somme? "); + bank.virement(from, to, in.nextDouble()); + }catch (CompteInexistantException e){ + nombreEssai++; +System.out.println("Nombre essais invalides: "+ nombreEssai); +} + + } + + static void menuEcheance() { + try{ + int num; + System.out.print("\nnumero du compte? "); + num=in.nextInt(); + + bank.echeance(num); + }catch (CompteInexistantException e){ + nombreEssai++; +System.out.println("Nombre essais invalides: "+ nombreEssai); +} + + } + + static void menuInterets() { + try{ + int num; + System.out.print("\nnumero du compte? "); + num=in.nextInt(); + bank.interets(num); + }catch (CompteInexistantException e){ + nombreEssai++; +System.out.println("Nombre essais invalides: "+ nombreEssai); +} + + } +} diff --git a/tp4_banque/banque/OperationNonValideException.class b/tp4_banque/banque/OperationNonValideException.class new file mode 100644 index 0000000..c859f3f Binary files /dev/null and b/tp4_banque/banque/OperationNonValideException.class differ diff --git a/tp4_banque/banque/OperationNonValideException.java b/tp4_banque/banque/OperationNonValideException.java new file mode 100644 index 0000000..8f1868c --- /dev/null +++ b/tp4_banque/banque/OperationNonValideException.java @@ -0,0 +1,5 @@ +public class OperationNonValideException extends Exception{ + public OperationNonValideException(){ + System.out.println("Opé non valide"); + } + } diff --git a/tp4_banque/source/Banque.java b/tp4_banque/source/Banque.java new file mode 100644 index 0000000..29246b2 --- /dev/null +++ b/tp4_banque/source/Banque.java @@ -0,0 +1,32 @@ +import java.util.*; + +public class Banque { + List comptes; + int nbComptes ; + public Banque(){ + + } + public int ouvrirCompte(){ + } + + public Compte getCompte(int i) { + } + + public void crediter(int i, double x){ + } + + public void debiter(int i, double x){ + } + + public double totalSolde(){ + } + + public String etat(int i){ + } + + public void etat() { + } + + public void virement(int numSrc, int numDest, double x){ + } +} \ No newline at end of file diff --git a/tp4_banque/source/Guichet.java b/tp4_banque/source/Guichet.java new file mode 100644 index 0000000..f9dfd28 --- /dev/null +++ b/tp4_banque/source/Guichet.java @@ -0,0 +1,71 @@ +import java.util.Scanner; + +public class Guichet { + static Scanner in = new Scanner(System.in); + // creation de la banque : + static Banque bank = new Banque(); + + public static void main (String[] args) { + int choix=0; + do { + menu(); + System.out.print("votre choix? "); + choix = in.nextInt(); + switch (choix) { + case 1 : // etat des comptes + bank.etat(); + break; + case 2 : // creer un nouveau compte + menuNouveauCompte(); + break; + case 3: // crediter un compte + menuCrediter(); + break; + case 4: // debiter un compte + menuDebiter(); + break; + case 5: // effectuer un virement + menuVirement(); + break; + case 0: // quitter + } + } while (choix!=0); + System.out.println("au revoir"); + } + + static void menu() { + System.out.println("\n1: etat des comptes\n2: creer un nouveau compte\n3: crediter un compte\n4: debiter un compte\n5: effectuer un virement\n0: quitter"); + } + + static void menuNouveauCompte() { + int num; + num=bank.ouvrirCompte(); + System.out.println("numero= "+num); + } + + static void menuCrediter() { + int num; + System.out.print("\nnumero du compte? "); + num=in.nextInt(); + System.out.print("somme? "); + bank.crediter(num, in.nextDouble()); + } + + static void menuDebiter() { + int num; + System.out.print("\nnumero du compte? "); + num=in.nextInt(); + System.out.print("somme? "); + bank.debiter(num, in.nextDouble()); + } + + static void menuVirement() { + int from, to; + System.out.print("\ncompte a debiter? "); + from=in.nextInt(); + System.out.print("compte a crediter? "); + to=in.nextInt(); + System.out.print("somme? "); + bank.virement(from, to, in.nextDouble()); + } +} \ No newline at end of file diff --git a/tp4_banque/test/.DS_Store b/tp4_banque/test/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/tp4_banque/test/.DS_Store differ diff --git a/tp4_banque/test/BanqueTest.class b/tp4_banque/test/BanqueTest.class new file mode 100644 index 0000000..1963663 Binary files /dev/null and b/tp4_banque/test/BanqueTest.class differ diff --git a/tp4_banque/test/BanqueTestV2.class b/tp4_banque/test/BanqueTestV2.class new file mode 100644 index 0000000..f3a10ee Binary files /dev/null and b/tp4_banque/test/BanqueTestV2.class differ diff --git a/tp4_banque/test/BanqueTestV3.class b/tp4_banque/test/BanqueTestV3.class new file mode 100644 index 0000000..76fd6a1 Binary files /dev/null and b/tp4_banque/test/BanqueTestV3.class differ diff --git a/tp4_banque/test/CompteEpargneTest.class b/tp4_banque/test/CompteEpargneTest.class new file mode 100644 index 0000000..2fdbd18 Binary files /dev/null and b/tp4_banque/test/CompteEpargneTest.class differ diff --git a/tp4_banque/test/CompteTest.class b/tp4_banque/test/CompteTest.class new file mode 100644 index 0000000..bb9884d Binary files /dev/null and b/tp4_banque/test/CompteTest.class differ diff --git a/tp4_banque/test/TestException.class b/tp4_banque/test/TestException.class new file mode 100644 index 0000000..72f7a6d Binary files /dev/null and b/tp4_banque/test/TestException.class differ diff --git a/tp4_banque/test/runTest.sh b/tp4_banque/test/runTest.sh new file mode 100755 index 0000000..53b4ff0 --- /dev/null +++ b/tp4_banque/test/runTest.sh @@ -0,0 +1,4 @@ +# !/bin/bash + +java -cp .:../banque:../../tp1/lib/junit-4.12.jar:../../tp1/lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore CompteTest CompteEpargneTest BanqueTest + diff --git a/tp4_banque/test/runV2Test.sh b/tp4_banque/test/runV2Test.sh new file mode 100755 index 0000000..a8ce4af --- /dev/null +++ b/tp4_banque/test/runV2Test.sh @@ -0,0 +1,4 @@ +# !/bin/bash + +java -cp .:../banque:../../tp1/lib/junit-4.12.jar:../../tp1/lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore CompteTest CompteEpargneTest BanqueTest BanqueTestV2 + diff --git a/tp4_banque/test/runV3Test.sh b/tp4_banque/test/runV3Test.sh new file mode 100755 index 0000000..db0fad5 --- /dev/null +++ b/tp4_banque/test/runV3Test.sh @@ -0,0 +1,4 @@ +# !/bin/bash + +java -cp .:../banque:../../tp1/lib/junit-4.12.jar:../../tp1/lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore CompteTest CompteEpargneTest BanqueTest BanqueTestV2 BanqueTestV3 + diff --git a/tp5_interfaces/tpBib/Application.class b/tp5_interfaces/tpBib/Application.class new file mode 100644 index 0000000..b718bda Binary files /dev/null and b/tp5_interfaces/tpBib/Application.class differ diff --git a/tp5_interfaces/tpBib/Application.java b/tp5_interfaces/tpBib/Application.java new file mode 100644 index 0000000..28926b3 --- /dev/null +++ b/tp5_interfaces/tpBib/Application.java @@ -0,0 +1,84 @@ +import java.util.Scanner; + +public class Application { + + static Scanner in = new Scanner(System.in); + public static void main(String[] argv) { + + Bibliotheque bib = new Bibliotheque(); + + //Ranger des ouvrages: + bib.add("I101",new Ouvrage("C","Kernighan")); + bib.add("L202",new Ouvrage("Germinal","Zola")); + bib.add("S303",new Ouvrage("Parapente","Ali Gali")); + bib.add("I345",new Ouvrage("Java","Eckel")); + bib.add("1",new Ouvrage("Test","E")); + bib.add("2",new Revue("Date","Eckel",20180000,1)); + bib.add("3",new Revue("PasDate","Teckel",20180514,1)); + bib.listing(); + + int choix=0; + do { + menu(); + System.out.print("votre choix? "); + choix = in.nextInt(); + switch (choix) { + case 1 : //emprunt + menuEmprunt(bib); + menuListing(bib); + break; + case 2 : //retour + menuRetourner(bib); + menuListing(bib); + break; + + case 3 : //affiche + menuListing(bib); + break; + case 0: // quitter + } + } while (choix!=0); + //Permettre a l'utilisateur d'emprunter/retourner un ouvrage + //en demandant son code. + //Transformer les exceptions en message d'erreur. + + + + + } + + static void menu() { + System.out.println("\n1: Emprunter\n2: Retourner\n3: Lister\n0: quitter"); + } + +static void menuEmprunt(Bibliotheque bib ) { + try{ + System.out.print("\ncode? "); + String code= in.next(); + + bib.emprunter(code); + + }catch (Exception e){ + e.printStackTrace(); + } + + } + + static void menuRetourner(Bibliotheque bib ) { + try{ + + System.out.print("\ncode? "); + String code=in.next(); + + bib.retourner(code); + }catch (OuvrageInconnuException e){ + e.printStackTrace(); + } + + } + + static void menuListing(Bibliotheque bib ) { + bib.listing(); + } + +} diff --git a/tp5_interfaces/tpBib/Bibliotheque$Comparateur.class b/tp5_interfaces/tpBib/Bibliotheque$Comparateur.class new file mode 100644 index 0000000..25afdd5 Binary files /dev/null and b/tp5_interfaces/tpBib/Bibliotheque$Comparateur.class differ diff --git a/tp5_interfaces/tpBib/Bibliotheque.class b/tp5_interfaces/tpBib/Bibliotheque.class new file mode 100644 index 0000000..8b66443 Binary files /dev/null and b/tp5_interfaces/tpBib/Bibliotheque.class differ diff --git a/tp5_interfaces/tpBib/Bibliotheque.java b/tp5_interfaces/tpBib/Bibliotheque.java new file mode 100644 index 0000000..f3e2c3d --- /dev/null +++ b/tp5_interfaces/tpBib/Bibliotheque.java @@ -0,0 +1,68 @@ +import java.util.*; + +public class Bibliotheque { + +//variables d'instances + protected Map ouvrages = new TreeMap(); + static final int date = 20180518; + +//methodes a programmer + public void add(String code, Ouvrage o){ + ouvrages.put(code,o); + + } + + + public int totalEmprunts(){ + int total = 0; + + for (Map.Entry o: ouvrages.entrySet()) { + Ouvrage ouvrage = o.getValue(); + total += ouvrage.compteur; + } + + return total; + + } + + public void listing(){ + for (Map.Entry o: ouvrages.entrySet()) { + Ouvrage ouvrage = o.getValue(); + System.out.println(""+ ouvrage.toString()); + } + } + + public void emprunter(String code)throws OuvrageInconnuException,NonDisponibleException,NonDispoException{ + try { + Revue revue = (Revue) ouvrages.get(code); + if(revue == null){ + throw new OuvrageInconnuException(); + } + revue.emprunter(date); + }catch(ClassCastException e){ + //e.printStackTrace(); + Ouvrage ouvrage = ouvrages.get(code); + if(ouvrage == null){ + throw new OuvrageInconnuException(); + } + ouvrage.emprunter(); + } + + + } + + public void retourner(String code)throws OuvrageInconnuException{ + Ouvrage ouvrage = ouvrages.get(code); + if(ouvrage == null){ + throw new OuvrageInconnuException(); + } + ouvrage.retourner(); + + } + + public TreeMap getOuvrage(){ + Arrays.sort(ouvrages, new ComparateurOuvrage()); + } + + +} diff --git a/tp5_interfaces/tpBib/ComparateurOuvrage.java b/tp5_interfaces/tpBib/ComparateurOuvrage.java new file mode 100644 index 0000000..4e37f54 --- /dev/null +++ b/tp5_interfaces/tpBib/ComparateurOuvrage.java @@ -0,0 +1,5 @@ +public class ComparateurOuvrage implements Comparator{ + public int compare(Ouvrage o1, Ouvrage o2){ + return o1.compareTo(o2); + } +} diff --git a/tp5_interfaces/tpBib/NonDispoException.class b/tp5_interfaces/tpBib/NonDispoException.class new file mode 100644 index 0000000..e1077af Binary files /dev/null and b/tp5_interfaces/tpBib/NonDispoException.class differ diff --git a/tp5_interfaces/tpBib/NonDispoException.java b/tp5_interfaces/tpBib/NonDispoException.java new file mode 100644 index 0000000..4472f82 --- /dev/null +++ b/tp5_interfaces/tpBib/NonDispoException.java @@ -0,0 +1,5 @@ +public class NonDispoException extends Exception { + NonDispoException(){ + super("Revue non empruntable"); + } +} diff --git a/tp5_interfaces/tpBib/NonDisponibleException.class b/tp5_interfaces/tpBib/NonDisponibleException.class new file mode 100644 index 0000000..df0a481 Binary files /dev/null and b/tp5_interfaces/tpBib/NonDisponibleException.class differ diff --git a/tp5_interfaces/tpBib/NonDisponibleException.java b/tp5_interfaces/tpBib/NonDisponibleException.java new file mode 100644 index 0000000..44ff8d1 --- /dev/null +++ b/tp5_interfaces/tpBib/NonDisponibleException.java @@ -0,0 +1,5 @@ +public class NonDisponibleException extends Exception { + NonDisponibleException(){ + super("Déjà emprunté"); + } +} diff --git a/tp5_interfaces/tpBib/Ouvrage.class b/tp5_interfaces/tpBib/Ouvrage.class new file mode 100644 index 0000000..b219c88 Binary files /dev/null and b/tp5_interfaces/tpBib/Ouvrage.class differ diff --git a/tp5_interfaces/tpBib/Ouvrage.java b/tp5_interfaces/tpBib/Ouvrage.java new file mode 100644 index 0000000..34802f3 --- /dev/null +++ b/tp5_interfaces/tpBib/Ouvrage.java @@ -0,0 +1,42 @@ +public class Ouvrage implements Comparable{ +//variables d'instance + protected String titre, auteur; + protected boolean emprunte; + protected int compteur; // nombre d'emprunts + +//methodes et constructeurs + public Ouvrage(String tit, String aut){ + this.titre = tit; + this.auteur = aut; + } + + public String toString(){ + return "Titre; "+titre+" Auteur; "+ auteur+" emprunter: "+ emprunte; + } + + public void emprunter() throws NonDisponibleException{ + if(this.emprunte == true){ + throw new NonDisponibleException(); + } else { + this.emprunte = true; + this.compteur ++; + } + } + + public void retourner(){ + this.emprunte = false; + } + + public int getCompteur(){ + return this.compteur; + } + + @Override + public int compareTo(Ouvrage ouvrage) { + if (this.compteur <= ouvrage.compteur) { + return -1; + } else { + return 1; + } + } +} diff --git a/tp5_interfaces/tpBib/OuvrageInconnuException.class b/tp5_interfaces/tpBib/OuvrageInconnuException.class new file mode 100644 index 0000000..8a41d59 Binary files /dev/null and b/tp5_interfaces/tpBib/OuvrageInconnuException.class differ diff --git a/tp5_interfaces/tpBib/OuvrageInconnuException.java b/tp5_interfaces/tpBib/OuvrageInconnuException.java new file mode 100644 index 0000000..2430fe7 --- /dev/null +++ b/tp5_interfaces/tpBib/OuvrageInconnuException.java @@ -0,0 +1,5 @@ +public class OuvrageInconnuException extends Exception { + OuvrageInconnuException(){ + super("Ouvrage non dispo"); + } +} diff --git a/tp5_interfaces/tpBib/Revue.class b/tp5_interfaces/tpBib/Revue.class new file mode 100644 index 0000000..b34d230 Binary files /dev/null and b/tp5_interfaces/tpBib/Revue.class differ diff --git a/tp5_interfaces/tpBib/Revue.java b/tp5_interfaces/tpBib/Revue.java new file mode 100644 index 0000000..6500162 --- /dev/null +++ b/tp5_interfaces/tpBib/Revue.java @@ -0,0 +1,28 @@ +public class Revue extends Ouvrage { + + protected int dateEdit; + protected int num; + + public Revue(String tit, String aut, int dateEdit, int num){ + super(tit,aut); + this.dateEdit = dateEdit; + this.num = num; + + } + + public void emprunter(int date) throws NonDisponibleException,NonDispoException{ + if(this.emprunte == true){ + throw new NonDisponibleException(); + } else { + if(date > dateEdit +7){ + this.emprunte = true; + this.compteur ++; + }else{ + throw new NonDispoException(); + } + } + } + + + +} diff --git a/tp_Test/.classpath b/tp_Test/.classpath new file mode 100644 index 0000000..373dce4 --- /dev/null +++ b/tp_Test/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tp_Test/.gitignore b/tp_Test/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/tp_Test/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/tp_Test/.project b/tp_Test/.project new file mode 100644 index 0000000..0cca178 --- /dev/null +++ b/tp_Test/.project @@ -0,0 +1,17 @@ + + + tp_Test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/tp_Test/.settings/org.eclipse.jdt.core.prefs b/tp_Test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/tp_Test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/tp_Test/source/ProgressionArithmetiqueTest.java b/tp_Test/source/ProgressionArithmetiqueTest.java new file mode 100644 index 0000000..f8235dc --- /dev/null +++ b/tp_Test/source/ProgressionArithmetiqueTest.java @@ -0,0 +1,40 @@ + +import java.util.*; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ProgressionArithmetiqueTest { + + + @Test + public void testConstructeur() throws TestException { + ProgressionArithmetique pa = new ProgressionArithmetique(2, 1); + try{ + assertEquals (pa.termes.size(), 1); + } + catch(AssertionError e){ + throw new TestException("*****Le premier terme doit etre place dans la liste de termes*****"); + } + catch(NoSuchFieldError e) { + throw new TestException("*****La variable d'instance termes doit etre une collection, une ArrayList*****"); + } + } + @Test + public void testNext() throws TestException { + ProgressionArithmetique pa = new ProgressionArithmetique(2, 1); + try{ + assertEquals (pa.termes.size(), 1); + pa.next(); + assertEquals (pa.termes.size(), 2); + assertTrue (pa.getTerme() == 3); + } + catch(AssertionError e){ + throw new TestException("*****Erreur dans le calcul de next() ou de getTerme()*****"); + } + catch(NoSuchFieldError e) { + throw new TestException("*****La variable d'instance termes doit etre une collection, une ArrayList*****"); + } + } +} diff --git a/tp_Test/source/ProgressionGeometriqueTest.java b/tp_Test/source/ProgressionGeometriqueTest.java new file mode 100644 index 0000000..bdfcc67 --- /dev/null +++ b/tp_Test/source/ProgressionGeometriqueTest.java @@ -0,0 +1,38 @@ +import java.util.*; + +import static org.junit.Assert.*; + +import org.junit.Test; +public class ProgressionGeometriqueTest { + + + @Test + public void testConstructeur() throws TestException { + ProgressionGeometrique pg = new ProgressionGeometrique(2, 1); + try{ + assertEquals (pg.termes.size(), 1); + } + catch(AssertionError e){ + throw new TestException("*****Le premier terme doit etre place dans la liste de termes*****"); + } + catch(NoSuchFieldError e) { + throw new TestException("*****La variable d'instance termes doit etre une collection, une ArrayList*****"); + } + } + @Test + public void testNext() throws TestException { + ProgressionGeometrique pg = new ProgressionGeometrique(2, 3); + try{ + assertEquals (pg.termes.size(), 1); + pg.next(); + assertEquals (pg.termes.size(), 2); + assertTrue (pg.getTerme() == 6); + } + catch(AssertionError e){ + throw new TestException("*****Erreur dans le calcul de next() ou de getTerme()*****"); + } + catch(NoSuchFieldError e) { + throw new TestException("*****La variable d'instance termes doit etre une collection, une ArrayList*****"); + } + } +} diff --git a/tp_Test/source/ProgressionHierarchieTest.java b/tp_Test/source/ProgressionHierarchieTest.java new file mode 100644 index 0000000..ddddfb1 --- /dev/null +++ b/tp_Test/source/ProgressionHierarchieTest.java @@ -0,0 +1,43 @@ + +import java.lang.reflect.Modifier; +import java.util.*; + +import static org.junit.Assert.*; + +import org.junit.Test; +public class ProgressionHierarchieTest { + @Test + public void testAbstractProgression() throws TestException { + try{ + assertTrue (Modifier.isAbstract(Progression.class.getModifiers())); + } + catch(AssertionError e){ + throw new TestException("*****La classe Progression doit etre abstraite*****"); + } + } + + @Test + public void testProgressionGeometrique() throws TestException { + try{ + assertTrue (ProgressionGeometrique.class.getDeclaredMethods().length==1); + assertTrue (ProgressionGeometrique.class.getDeclaredMethod("next").getReturnType()==void.class); + } + catch(AssertionError e){ + throw new TestException("*****Dans la classe ProgressionGeometrique vous ne devez redefinir que next()*****"); + } catch (NoSuchMethodException e) { + throw new TestException("*****Dans la classe ProgressionGeometrique vous ne devez redefinir que next()*****"); + } + } + @Test + public void testProgressionArithmetique() throws TestException { + try{ + assertTrue (ProgressionArithmetique.class.getDeclaredMethods().length==1); + assertTrue (ProgressionArithmetique.class.getDeclaredMethod("next").getReturnType()==void.class); + } + catch(AssertionError e){ + throw new TestException("*****Dans la classe ProgressionArithmetique vous ne devez redefinir que next()*****"); + } catch (NoSuchMethodException e) { + throw new TestException("*****Dans la classe ProgressionArithmetique vous ne devez redefinir que next()*****"); + } + } +} diff --git a/tp_Test/src/ProgressionArithmetique.java b/tp_Test/src/ProgressionArithmetique.java new file mode 100644 index 0000000..f80d082 --- /dev/null +++ b/tp_Test/src/ProgressionArithmetique.java @@ -0,0 +1,62 @@ +import java.util.*; + +public class ProgressionArithmetique { + + ArrayList termes; + double raison; + int rang; + + public ProgressionArithmetique(double terme1, double raison) { + termes = new ArrayList(); + termes.add(terme1); + this.setRang(0); + this.setRaison(raison); + } + + public int getRang() { + return this.rang; + } + + public void setRang(int rang) { + this.rang = rang; + } + + public double getRaison() { + return this.raison; + } + + public void setRaison(double raison) { + this.raison = raison; + } + + void next() { + double d = this.termes.get(getRang()); + d += raison; + termes.add(d); + rang++; + } + + /** + * Calcul les n prochaines itérations + */ + void next(int n) { + for (int i = 0; i < n; i++) { + next(); + } + } + + /** + * Récupère le dernier terme + */ + public double getTerme() { + return termes.get(getRang()); + } + + public String toString() { + String res = "progression:"; + for (Double d : termes) { + res += " " + d; + } + return res; + } +} diff --git a/tp_Test/src/ProgressionGeometrique.java b/tp_Test/src/ProgressionGeometrique.java new file mode 100644 index 0000000..a76b97e --- /dev/null +++ b/tp_Test/src/ProgressionGeometrique.java @@ -0,0 +1,62 @@ +import java.util.*; + +public class ProgressionGeometrique { + + ArrayList termes; + double raison; + int rang; + + public ProgressionGeometrique(double terme1, double raison) { + termes = new ArrayList(); + termes.add(terme1); + this.setRang(0); + this.setRaison(raison); + } + + public int getRang() { + return this.rang; + } + + public void setRang(int rang) { + this.rang = rang; + } + + public double getRaison() { + return this.raison; + } + + public void setRaison(double raison) { + this.raison = raison; + } + + void next() { + double d = this.termes.get(getRang()); + d *= raison; + termes.add(d); + rang++; + } + + /** + * Calcul les n prochaines itérations + */ + void next(int n) { + for (int i = 0; i < n; i++) { + next(); + } + } + + /** + * Récupère le dernier terme + */ + public double getTerme() { + return termes.get(getRang()); + } + + public String toString() { + String res = "progression:"; + for (Double d : termes) { + res += " " + d; + } + return res; + } +} diff --git a/tp_Test/src/ProgressionGeometriqueTest.java b/tp_Test/src/ProgressionGeometriqueTest.java new file mode 100644 index 0000000..2284ae5 --- /dev/null +++ b/tp_Test/src/ProgressionGeometriqueTest.java @@ -0,0 +1,26 @@ +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class ProgressionGeometriqueTest { + + @Test + public void testConstructeur() { + ProgressionGeometrique pg = new ProgressionGeometrique(10, 5); + + assertEquals(pg.termes.size(), 1); + + } + + @Test + public void testNext() { + ProgressionGeometrique pg = new ProgressionGeometrique(10, 5); + + assertEquals(pg.termes.size(), 1); + + pg.next(); + assertEquals(pg.termes.size(), 2); + assertEquals(pg.getTerme(), 50, 0); + + } +} diff --git a/tp_Test/src/TestArithmetique.java b/tp_Test/src/TestArithmetique.java new file mode 100644 index 0000000..761389c --- /dev/null +++ b/tp_Test/src/TestArithmetique.java @@ -0,0 +1,26 @@ +import java.util.*; + +public class TestArithmetique { + + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + System.out.print("\npremier terme? "); + double d = sc.nextDouble(); + System.out.print("\nraison? "); + double raison = sc.nextDouble(); + ProgressionArithmetique pa = new ProgressionArithmetique(d,raison); + + System.out.print("\nnext (y/n)? "); + char next = sc.next().charAt(0); + while(next == 'y'){ + pa.next(); + System.out.println("\n-> "+pa.getTerme()); + + System.out.print("next (y/n)? "); + next = sc.next().charAt(0); + } + System.out.print("\nnb termes supplementaires? "); + pa.next(sc.nextInt()); + System.out.println("\n"+pa.toString()); + } +} diff --git a/tp_bibliotheque/.classpath b/tp_bibliotheque/.classpath new file mode 100644 index 0000000..373dce4 --- /dev/null +++ b/tp_bibliotheque/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tp_bibliotheque/.gitignore b/tp_bibliotheque/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/tp_bibliotheque/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/tp_bibliotheque/.project b/tp_bibliotheque/.project new file mode 100644 index 0000000..2869806 --- /dev/null +++ b/tp_bibliotheque/.project @@ -0,0 +1,17 @@ + + + tp_bibliotheque + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/tp_bibliotheque/.settings/org.eclipse.jdt.core.prefs b/tp_bibliotheque/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/tp_bibliotheque/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/tp_bibliotheque/src/src/Application.java b/tp_bibliotheque/src/src/Application.java new file mode 100644 index 0000000..f1e7cf0 --- /dev/null +++ b/tp_bibliotheque/src/src/Application.java @@ -0,0 +1,85 @@ +package src; +import java.util.Scanner; + +public class Application { + + static Scanner in = new Scanner(System.in); + public static void main(String[] argv) { + + Bibliotheque bib = new Bibliotheque(); + + //Ranger des ouvrages: + bib.add("I101",new Ouvrage("C","Kernighan")); + bib.add("L202",new Ouvrage("Germinal","Zola")); + bib.add("S303",new Ouvrage("Parapente","Ali Gali")); + bib.add("I345",new Ouvrage("Java","Eckel")); + bib.add("1",new Ouvrage("Test","E")); + bib.add("2",new Revue("Date","Eckel",20180000,1)); + bib.add("3",new Revue("PasDate","Teckel",20180514,1)); + bib.listing(); + + int choix=0; + do { + menu(); + System.out.print("votre choix? "); + choix = in.nextInt(); + switch (choix) { + case 1 : //emprunt + menuEmprunt(bib); + menuListing(bib); + break; + case 2 : //retour + menuRetourner(bib); + menuListing(bib); + break; + + case 3 : //affiche + menuListing(bib); + break; + case 0: // quitter + } + } while (choix!=0); + //Permettre a l'utilisateur d'emprunter/retourner un ouvrage + //en demandant son code. + //Transformer les exceptions en message d'erreur. + + + + + } + + static void menu() { + System.out.println("\n1: Emprunter\n2: Retourner\n3: Lister\n0: quitter"); + } + +static void menuEmprunt(Bibliotheque bib ) { + try{ + System.out.print("\ncode? "); + String code= in.next(); + + bib.emprunter(code); + + }catch (Exception e){ + e.printStackTrace(); + } + + } + + static void menuRetourner(Bibliotheque bib ) { + try{ + + System.out.print("\ncode? "); + String code=in.next(); + + bib.retourner(code); + }catch (OuvrageInconnuException e){ + e.printStackTrace(); + } + + } + + static void menuListing(Bibliotheque bib ) { + bib.listing(); + } + +} diff --git a/tp_bibliotheque/src/src/Bibliotheque.java b/tp_bibliotheque/src/src/Bibliotheque.java new file mode 100644 index 0000000..a59b46c --- /dev/null +++ b/tp_bibliotheque/src/src/Bibliotheque.java @@ -0,0 +1,70 @@ +package src; +import java.util.Map; +import java.util.TreeMap; + +public class Bibliotheque { + +//variables d'instances + protected Map ouvrages = new TreeMap(); + static final int date = 20180518; + +//methodes a programmer + public void add(String code, Ouvrage o){ + ouvrages.put(code,o); + + } + + + public int totalEmprunts(){ + int total = 0; + + for (Map.Entry o: ouvrages.entrySet()) { + Ouvrage ouvrage = o.getValue(); + total += ouvrage.compteur; + } + + return total; + + } + + public void listing(){ + for (Map.Entry o: ouvrages.entrySet()) { + Ouvrage ouvrage = o.getValue(); + System.out.println(""+ ouvrage.toString()); + } + } + + public void emprunter(String code)throws OuvrageInconnuException,NonDisponibleException,NonDispoException{ + try { + Revue revue = (Revue) ouvrages.get(code); + if(revue == null){ + throw new OuvrageInconnuException(); + } + revue.emprunter(date); + }catch(ClassCastException e){ + //e.printStackTrace(); + Ouvrage ouvrage = ouvrages.get(code); + if(ouvrage == null){ + throw new OuvrageInconnuException(); + } + ouvrage.emprunter(); + } + + + } + + public void retourner(String code)throws OuvrageInconnuException{ + Ouvrage ouvrage = ouvrages.get(code); + if(ouvrage == null){ + throw new OuvrageInconnuException(); + } + ouvrage.retourner(); + + } + + /*public TreeMap getOuvrage(){ + Arrays.sort(ouvrages, new ComparateurOuvrage()); + }*/ + + +} diff --git a/tp_bibliotheque/src/src/ComparateurOuvrage.java b/tp_bibliotheque/src/src/ComparateurOuvrage.java new file mode 100644 index 0000000..f63ed5d --- /dev/null +++ b/tp_bibliotheque/src/src/ComparateurOuvrage.java @@ -0,0 +1,8 @@ +package src; +import java.util.Comparator; + +public class ComparateurOuvrage implements Comparator{ + public int compare(Ouvrage o1, Ouvrage o2){ + return o1.compareTo(o2); + } +} diff --git a/tp_bibliotheque/src/src/NonDispoException.java b/tp_bibliotheque/src/src/NonDispoException.java new file mode 100644 index 0000000..420a993 --- /dev/null +++ b/tp_bibliotheque/src/src/NonDispoException.java @@ -0,0 +1,6 @@ +package src; +public class NonDispoException extends Exception { + NonDispoException(){ + super("Revue non empruntable"); + } +} diff --git a/tp_bibliotheque/src/src/NonDisponibleException.java b/tp_bibliotheque/src/src/NonDisponibleException.java new file mode 100644 index 0000000..f8cf01f --- /dev/null +++ b/tp_bibliotheque/src/src/NonDisponibleException.java @@ -0,0 +1,6 @@ +package src; +public class NonDisponibleException extends Exception { + NonDisponibleException(){ + super("Déjà emprunté"); + } +} diff --git a/tp_bibliotheque/src/src/Ouvrage.java b/tp_bibliotheque/src/src/Ouvrage.java new file mode 100644 index 0000000..6051961 --- /dev/null +++ b/tp_bibliotheque/src/src/Ouvrage.java @@ -0,0 +1,73 @@ +package src; + +public class Ouvrage implements Comparable { + + // variables d'instance + protected String titre, auteur; + protected boolean emprunte; + protected int compteur; // nombre d'emprunts + + // methodes et constructeurs + public Ouvrage(String tit, String aut) { + this.titre = tit; + this.auteur = aut; + } + + public String toString() { + return "Titre; " + titre + " Auteur; " + auteur + " emprunter: " + emprunte; + } + + public void emprunter() throws NonDisponibleException { + if (this.emprunte == true) { + throw new NonDisponibleException(); + } else { + this.emprunte = true; + this.compteur++; + } + } + + public void retourner() { + this.emprunte = false; + } + + public int getCompteur() { + return this.compteur; + } + + @Override + public int compareTo(Ouvrage ouvrage) { + if (this.compteur <= ouvrage.compteur) { + return -1; + } else { + return 1; + } + } + + public void setTitre(String titre) { + this.titre = titre; + } + + public void setAuteur(String auteur) { + this.auteur = auteur; + } + + public void setEmprunte(boolean emprunte) { + this.emprunte = emprunte; + } + + public void setCompteur(int compteur) { + this.compteur = compteur; + } + + public String getTitre() { + return titre; + } + + public String getAuteur() { + return auteur; + } + + public boolean isEmprunte() { + return emprunte; + } +} diff --git a/tp_bibliotheque/src/src/OuvrageInconnuException.java b/tp_bibliotheque/src/src/OuvrageInconnuException.java new file mode 100644 index 0000000..88e7924 --- /dev/null +++ b/tp_bibliotheque/src/src/OuvrageInconnuException.java @@ -0,0 +1,6 @@ +package src; +public class OuvrageInconnuException extends Exception { + OuvrageInconnuException(){ + super("Ouvrage non dispo"); + } +} diff --git a/tp_bibliotheque/src/src/Revue.java b/tp_bibliotheque/src/src/Revue.java new file mode 100644 index 0000000..25377be --- /dev/null +++ b/tp_bibliotheque/src/src/Revue.java @@ -0,0 +1,29 @@ +package src; +public class Revue extends Ouvrage { + + protected int dateEdit; + protected int num; + + public Revue(String tit, String aut, int dateEdit, int num){ + super(tit,aut); + this.dateEdit = dateEdit; + this.num = num; + + } + + public void emprunter(int date) throws NonDisponibleException,NonDispoException{ + if(emprunte){ + throw new NonDisponibleException(); + } else { + if(date > dateEdit +7){ + this.emprunte = true; + this.compteur ++; + }else{ + throw new NonDispoException(); + } + } + } + + + +} diff --git a/tp_bibliotheque/src/test/OuvrageTest.java b/tp_bibliotheque/src/test/OuvrageTest.java new file mode 100644 index 0000000..707e23a --- /dev/null +++ b/tp_bibliotheque/src/test/OuvrageTest.java @@ -0,0 +1,45 @@ +package test; + + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +import src.NonDisponibleException; +import src.Ouvrage; + +public class OuvrageTest { + + public Ouvrage o; + + @Before + public void initVals(){ + o = new Ouvrage("test","vinz"); + } + + @Test + public void emprunterValeurEmprunteTest() throws NonDisponibleException{ + assertTrue(o.isEmprunte()==false); + o.emprunter(); + + assertTrue(o.isEmprunte()==true); + + } + + @Test + public void emprunterValeurCompteurTest() throws NonDisponibleException{ + assertTrue(o.getCompteur()==0); + o.emprunter(); + + assertTrue(o.getCompteur()==1); + + } + + @Test(expected = NonDisponibleException.class) + public void emprunterExceptionLanceeTest() throws NonDisponibleException{ + o.emprunter(); + o.emprunter(); + } + +} diff --git a/tp_bibliotheque/src/test/RevueTest.java b/tp_bibliotheque/src/test/RevueTest.java new file mode 100644 index 0000000..7c7b354 --- /dev/null +++ b/tp_bibliotheque/src/test/RevueTest.java @@ -0,0 +1,47 @@ +package test; + + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; +import src.*; + +public class RevueTest { + + public Ouvrage o; + public Revue r1; + public Revue r2; + + @Before + public void initVals(){ + o = new Ouvrage("test","vinz"); + r1 = new Revue("test2", "vinz", 20180500, 1); + r2 = new Revue("test2", "vinz", 20180517, 1); + } + + @Test + public void emprunterValeurEmprunteTest() throws NonDisponibleException{ + assertTrue(r1.isEmprunte()==false); + r1.emprunter(); + + assertTrue(r1.isEmprunte()==true); + + } + + @Test + public void emprunterValeurCompteurTest() throws NonDisponibleException{ + assertTrue(r1.getCompteur()==0); + r1.emprunter(); + + assertTrue(r1.getCompteur()==1); + + } + + @Test(expected = NonDispoException.class) + public void emprunterExceptionLanceeTest() throws NonDispoException, NonDisponibleException{ + r2.emprunter(20180518); + + } + +} -- libgit2 0.21.2