From fed1c83c49ea1a726cfc2e492ba464a371483146 Mon Sep 17 00:00:00 2001 From: Vincent Benoist Date: Wed, 11 Apr 2018 12:24:25 +0200 Subject: [PATCH] tp2 et 3 --- tp2_banques/tp2/comptes/Banque.class | Bin 0 -> 482 bytes tp2_banques/tp2/comptes/Banque.java | 15 +++++++++++++++ tp2_banques/tp2/comptes/Compte.class | Bin 0 -> 1145 bytes tp2_banques/tp2/comptes/Compte.java | 47 +++++++++++++++++++++++++++++++++++++++++++++++ tp2_banques/tp2/comptes/CompteEpargne.class | Bin 0 -> 1086 bytes tp2_banques/tp2/comptes/CompteEpargne.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ tp2_banques/tp2/comptes/TestComptes.class | Bin 0 -> 928 bytes tp2_banques/tp2/comptes/TestComptes.java | 40 ++++++++++++++++++++++++++++++++++++++++ tp2_banques/tp2/lib/hamcrest-core-1.3.jar | Bin 0 -> 45024 bytes tp2_banques/tp2/lib/junit-4.12.jar | Bin 0 -> 314932 bytes tp2_banques/tp2/operations_historisees/Banque.class | Bin 0 -> 482 bytes tp2_banques/tp2/operations_historisees/Compte.class | Bin 0 -> 2373 bytes tp2_banques/tp2/operations_historisees/Compte.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tp2_banques/tp2/operations_historisees/CompteEpargne.class | Bin 0 -> 1079 bytes tp2_banques/tp2/operations_historisees/CompteEpargne.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ tp2_banques/tp2/operations_historisees/TestComptes.class | Bin 0 -> 928 bytes tp2_banques/tp2/test/BanqueTest.class | Bin 0 -> 3372 bytes tp2_banques/tp2/test/CompteEpargneTest.class | Bin 0 -> 3925 bytes tp2_banques/tp2/test/CompteHistoriqueTest.class | Bin 0 -> 6025 bytes tp2_banques/tp2/test/CompteTest.class | Bin 0 -> 3481 bytes tp2_banques/tp2/test/TestException.class | Bin 0 -> 614 bytes tp2_banques/tp2/test/runHistoriqueTest.sh | 3 +++ tp2_banques/tp2/test/runTest.sh | 4 ++++ tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.class | Bin 0 -> 1738 bytes tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.java | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tp3_polymorph/tp3/arithmetic/TestArithmetique.class | Bin 0 -> 1371 bytes tp3_polymorph/tp3/arithmetic/TestArithmetique.java | 26 ++++++++++++++++++++++++++ tp3_polymorph/tp3/geometric/ProgressionGeometrique.class | Bin 0 -> 1736 bytes tp3_polymorph/tp3/geometric/ProgressionGeometrique.java | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tp3_polymorph/tp3/geometric/TestGeometrique.class | Bin 0 -> 1368 bytes tp3_polymorph/tp3/geometric/TestGeometrique.java | 26 ++++++++++++++++++++++++++ tp3_polymorph/tp3/hierarchic/Progression.class | Bin 0 -> 1620 bytes tp3_polymorph/tp3/hierarchic/Progression.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tp3_polymorph/tp3/hierarchic/ProgressionArithmetique.class | Bin 0 -> 652 bytes tp3_polymorph/tp3/hierarchic/ProgressionArithmetique.java | 16 ++++++++++++++++ tp3_polymorph/tp3/hierarchic/ProgressionGeometrique.class | Bin 0 -> 650 bytes tp3_polymorph/tp3/hierarchic/ProgressionGeometrique.java | 17 +++++++++++++++++ tp3_polymorph/tp3/hierarchic/Test.class | Bin 0 -> 1605 bytes tp3_polymorph/tp3/hierarchic/Test.java | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ tp3_polymorph/tp3/hierarchic/TestArithmetique.class | Bin 0 -> 1371 bytes tp3_polymorph/tp3/hierarchic/TestGeometrique.class | Bin 0 -> 1368 bytes tp3_polymorph/tp3/lib/hamcrest-core-1.3.jar | Bin 0 -> 45024 bytes tp3_polymorph/tp3/lib/junit-4.12.jar | Bin 0 -> 314932 bytes tp3_polymorph/tp3/test/ProgressionArithmetiqueTest.class | Bin 0 -> 1646 bytes tp3_polymorph/tp3/test/ProgressionGeometriqueTest.class | Bin 0 -> 1652 bytes tp3_polymorph/tp3/test/ProgressionHierarchieTest.class | Bin 0 -> 1811 bytes tp3_polymorph/tp3/test/TestException.class | Bin 0 -> 614 bytes tp3_polymorph/tp3/test/runHierarchieTest.sh | 3 +++ tp3_polymorph/tp3/test/runTest.sh | 4 ++++ 49 files changed, 644 insertions(+), 0 deletions(-) create mode 100644 tp2_banques/tp2/comptes/Banque.class create mode 100644 tp2_banques/tp2/comptes/Banque.java create mode 100644 tp2_banques/tp2/comptes/Compte.class create mode 100644 tp2_banques/tp2/comptes/Compte.java create mode 100644 tp2_banques/tp2/comptes/CompteEpargne.class create mode 100644 tp2_banques/tp2/comptes/CompteEpargne.java create mode 100644 tp2_banques/tp2/comptes/TestComptes.class create mode 100644 tp2_banques/tp2/comptes/TestComptes.java create mode 100644 tp2_banques/tp2/lib/hamcrest-core-1.3.jar create mode 100644 tp2_banques/tp2/lib/junit-4.12.jar create mode 100644 tp2_banques/tp2/operations_historisees/Banque.class create mode 100644 tp2_banques/tp2/operations_historisees/Compte.class create mode 100644 tp2_banques/tp2/operations_historisees/Compte.java create mode 100644 tp2_banques/tp2/operations_historisees/CompteEpargne.class create mode 100644 tp2_banques/tp2/operations_historisees/CompteEpargne.java create mode 100644 tp2_banques/tp2/operations_historisees/TestComptes.class create mode 100644 tp2_banques/tp2/test/BanqueTest.class create mode 100644 tp2_banques/tp2/test/CompteEpargneTest.class create mode 100644 tp2_banques/tp2/test/CompteHistoriqueTest.class create mode 100644 tp2_banques/tp2/test/CompteTest.class create mode 100644 tp2_banques/tp2/test/TestException.class create mode 100755 tp2_banques/tp2/test/runHistoriqueTest.sh create mode 100755 tp2_banques/tp2/test/runTest.sh create mode 100644 tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.class create mode 100644 tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.java create mode 100644 tp3_polymorph/tp3/arithmetic/TestArithmetique.class create mode 100644 tp3_polymorph/tp3/arithmetic/TestArithmetique.java create mode 100644 tp3_polymorph/tp3/geometric/ProgressionGeometrique.class create mode 100644 tp3_polymorph/tp3/geometric/ProgressionGeometrique.java create mode 100644 tp3_polymorph/tp3/geometric/TestGeometrique.class create mode 100644 tp3_polymorph/tp3/geometric/TestGeometrique.java create mode 100644 tp3_polymorph/tp3/hierarchic/Progression.class create mode 100644 tp3_polymorph/tp3/hierarchic/Progression.java create mode 100644 tp3_polymorph/tp3/hierarchic/ProgressionArithmetique.class create mode 100644 tp3_polymorph/tp3/hierarchic/ProgressionArithmetique.java create mode 100644 tp3_polymorph/tp3/hierarchic/ProgressionGeometrique.class create mode 100644 tp3_polymorph/tp3/hierarchic/ProgressionGeometrique.java create mode 100644 tp3_polymorph/tp3/hierarchic/Test.class create mode 100644 tp3_polymorph/tp3/hierarchic/Test.java create mode 100644 tp3_polymorph/tp3/hierarchic/TestArithmetique.class create mode 100644 tp3_polymorph/tp3/hierarchic/TestGeometrique.class create mode 100644 tp3_polymorph/tp3/lib/hamcrest-core-1.3.jar create mode 100644 tp3_polymorph/tp3/lib/junit-4.12.jar create mode 100644 tp3_polymorph/tp3/test/ProgressionArithmetiqueTest.class create mode 100644 tp3_polymorph/tp3/test/ProgressionGeometriqueTest.class create mode 100644 tp3_polymorph/tp3/test/ProgressionHierarchieTest.class create mode 100644 tp3_polymorph/tp3/test/TestException.class create mode 100755 tp3_polymorph/tp3/test/runHierarchieTest.sh create mode 100755 tp3_polymorph/tp3/test/runTest.sh diff --git a/tp2_banques/tp2/comptes/Banque.class b/tp2_banques/tp2/comptes/Banque.class new file mode 100644 index 0000000..622452a Binary files /dev/null and b/tp2_banques/tp2/comptes/Banque.class differ diff --git a/tp2_banques/tp2/comptes/Banque.java b/tp2_banques/tp2/comptes/Banque.java new file mode 100644 index 0000000..0a562a6 --- /dev/null +++ b/tp2_banques/tp2/comptes/Banque.java @@ -0,0 +1,15 @@ +public class Banque{ + + public void crediter(Compte c, double valeur){ + c.crediter(valeur); + } + + public void debiter(Compte c, double valeur){ + c.debiter(valeur); + } + + public String etat(Compte c){ + return c.toString(); + } + +} diff --git a/tp2_banques/tp2/comptes/Compte.class b/tp2_banques/tp2/comptes/Compte.class new file mode 100644 index 0000000..374932f Binary files /dev/null and b/tp2_banques/tp2/comptes/Compte.class differ diff --git a/tp2_banques/tp2/comptes/Compte.java b/tp2_banques/tp2/comptes/Compte.java new file mode 100644 index 0000000..f6aa85e --- /dev/null +++ b/tp2_banques/tp2/comptes/Compte.java @@ -0,0 +1,47 @@ + + +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 "Votre solde actuel est de "+solde()+" ("+getCredit()+" - "+getDebit()+")"; + } + +} diff --git a/tp2_banques/tp2/comptes/CompteEpargne.class b/tp2_banques/tp2/comptes/CompteEpargne.class new file mode 100644 index 0000000..9f7be85 Binary files /dev/null and b/tp2_banques/tp2/comptes/CompteEpargne.class differ diff --git a/tp2_banques/tp2/comptes/CompteEpargne.java b/tp2_banques/tp2/comptes/CompteEpargne.java new file mode 100644 index 0000000..d3a48ce --- /dev/null +++ b/tp2_banques/tp2/comptes/CompteEpargne.java @@ -0,0 +1,44 @@ + +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(); +// return (soldeCredit()-soldeDebit())*getInteret(); + } + + public void echeance(){ + crediter(interets()); + } + + public void debiter(double val){ + if((getCredit()-val)>0){ + setDebit(getDebit()+val); + + } + } + + 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(); + } + +} diff --git a/tp2_banques/tp2/comptes/TestComptes.class b/tp2_banques/tp2/comptes/TestComptes.class new file mode 100644 index 0000000..12c8e04 Binary files /dev/null and b/tp2_banques/tp2/comptes/TestComptes.class differ diff --git a/tp2_banques/tp2/comptes/TestComptes.java b/tp2_banques/tp2/comptes/TestComptes.java new file mode 100644 index 0000000..0919b48 --- /dev/null +++ b/tp2_banques/tp2/comptes/TestComptes.java @@ -0,0 +1,40 @@ + + +public class TestComptes{ + + public static void main(String[] args){ + + Compte unCompte = new Compte(); + CompteEpargne unCE = new CompteEpargne(); + System.out.println(unCompte.toString()); + System.out.println(unCE.toString()); + + unCompte.crediter(100.0); + unCE.crediter(200.0); + + System.out.println(unCompte.toString()); + System.out.println(unCE.toString()); + //unCompte.etat(); + System.out.println(unCE.etat()); + + //unCE=unCompte; -> incompatibletype + + + Banque b = new Banque(); + b.crediter(unCompte, 10); + b.debiter(unCompte, 235); + System.out.println(b.etat(unCompte)); + + b.crediter(unCE, 10); + b.debiter(unCE, 235); + System.out.println(b.etat(unCE)); + + unCompte=unCE; + + b.crediter(unCompte, 10); + b.debiter(unCompte, 235); + System.out.println(b.etat(unCompte)); + } + + +} diff --git a/tp2_banques/tp2/lib/hamcrest-core-1.3.jar b/tp2_banques/tp2/lib/hamcrest-core-1.3.jar new file mode 100644 index 0000000..9d5fe16 Binary files /dev/null and b/tp2_banques/tp2/lib/hamcrest-core-1.3.jar differ diff --git a/tp2_banques/tp2/lib/junit-4.12.jar b/tp2_banques/tp2/lib/junit-4.12.jar new file mode 100644 index 0000000..3a7fc26 Binary files /dev/null and b/tp2_banques/tp2/lib/junit-4.12.jar differ diff --git a/tp2_banques/tp2/operations_historisees/Banque.class b/tp2_banques/tp2/operations_historisees/Banque.class new file mode 100644 index 0000000..622452a Binary files /dev/null and b/tp2_banques/tp2/operations_historisees/Banque.class differ diff --git a/tp2_banques/tp2/operations_historisees/Compte.class b/tp2_banques/tp2/operations_historisees/Compte.class new file mode 100644 index 0000000..49486fe Binary files /dev/null and b/tp2_banques/tp2/operations_historisees/Compte.class differ diff --git a/tp2_banques/tp2/operations_historisees/Compte.java b/tp2_banques/tp2/operations_historisees/Compte.java new file mode 100644 index 0000000..4223402 --- /dev/null +++ b/tp2_banques/tp2/operations_historisees/Compte.java @@ -0,0 +1,114 @@ + + +public class Compte { + + int MAX_OPERATIONS = 10; + + private double credits[] = new double[MAX_OPERATIONS]; + private double debits[] = new double[MAX_OPERATIONS]; + private int dernierCredit=0; + private int dernierDebit=0; + + public Compte(){ + + } + + public Compte(double x){ + crediter(x); + } + + + public int getDernierCredit(){ + return dernierCredit; + } + + public int getDernierDebit(){ + return dernierDebit; + } + + public void setDernierCredit(int i){ + this.dernierCredit=i; + } + + public void setDernierDebit(int i){ + this.dernierDebit=i; + } + + public double getCredit(int indice){ + return credits[indice]; + } + + public double getDebit(int indice){ + return debits[indice]; + } + + public void setCredit(int indice, double d){ + credits[indice]=d; + } + + public void setDebit(int indice, double d){ + debits[indice]=d; + } + + public void crediter(double x){ + if(getDernierCredit()+1>MAX_OPERATIONS){ + double sd = soldeCredit(); + this.credits = new double[MAX_OPERATIONS]; + setCredit(0, sd); + } else { + setCredit(getDernierCredit(),x); + setDernierCredit(getDernierCredit()+1); + } + } + + public void debiter(double x){ + + + if(getDernierDebit()+1>MAX_OPERATIONS){ + double sd = soldeDebit(); + this.debits = new double[MAX_OPERATIONS]; + setDebit(0, sd); + } else { + setDebit(getDernierDebit(),x); + setDernierDebit(getDernierDebit()+1); + } + } + + public double soldeCredit(){ + double res = 0; + if(getDernierCredit()>0){ + for(int i = 0; i<=getDernierCredit(); i++){ + res+=getCredit(i); + } + } + return res; + } + + public double soldeDebit(){ + double res = 0; + if(getDernierDebit()>0){ + for(int i = 0; i<=getDernierDebit(); i++){ + res+=getDebit(i); + } + } + return res; + } + + public double solde(){ + return soldeCredit()-soldeDebit(); + } + + public String toString(){ + String res=""; + for(int i = 0; i<=getDernierCredit(); i++){ + res+="Credit"+i+"= "+getCredit(i)+"\n"; + } + res+="\n"; + for(int i = 0; i<=getDernierDebit(); i++){ + res+="Debit"+i+"= "+getDebit(i)+"\n"; + } + res+="\nSolde final:"+solde()+".\n"; + return res; + } + +} diff --git a/tp2_banques/tp2/operations_historisees/CompteEpargne.class b/tp2_banques/tp2/operations_historisees/CompteEpargne.class new file mode 100644 index 0000000..695d4b7 Binary files /dev/null and b/tp2_banques/tp2/operations_historisees/CompteEpargne.class differ diff --git a/tp2_banques/tp2/operations_historisees/CompteEpargne.java b/tp2_banques/tp2/operations_historisees/CompteEpargne.java new file mode 100644 index 0000000..900cc0c --- /dev/null +++ b/tp2_banques/tp2/operations_historisees/CompteEpargne.java @@ -0,0 +1,44 @@ + +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(); + return (soldeCredit()-soldeDebit())*getInteret(); + } + + public void echeance(){ + crediter(interets()); + } + + public void debiter(double val){ + if((soldeCredit()-val)>0){ + super.debiter(soldeDebit()+val); + + } + } + + 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(); + } + +} diff --git a/tp2_banques/tp2/operations_historisees/TestComptes.class b/tp2_banques/tp2/operations_historisees/TestComptes.class new file mode 100644 index 0000000..12c8e04 Binary files /dev/null and b/tp2_banques/tp2/operations_historisees/TestComptes.class differ diff --git a/tp2_banques/tp2/test/BanqueTest.class b/tp2_banques/tp2/test/BanqueTest.class new file mode 100644 index 0000000..2baa5a1 Binary files /dev/null and b/tp2_banques/tp2/test/BanqueTest.class differ diff --git a/tp2_banques/tp2/test/CompteEpargneTest.class b/tp2_banques/tp2/test/CompteEpargneTest.class new file mode 100644 index 0000000..2fdbd18 Binary files /dev/null and b/tp2_banques/tp2/test/CompteEpargneTest.class differ diff --git a/tp2_banques/tp2/test/CompteHistoriqueTest.class b/tp2_banques/tp2/test/CompteHistoriqueTest.class new file mode 100644 index 0000000..ad71f39 Binary files /dev/null and b/tp2_banques/tp2/test/CompteHistoriqueTest.class differ diff --git a/tp2_banques/tp2/test/CompteTest.class b/tp2_banques/tp2/test/CompteTest.class new file mode 100644 index 0000000..a7e3010 Binary files /dev/null and b/tp2_banques/tp2/test/CompteTest.class differ diff --git a/tp2_banques/tp2/test/TestException.class b/tp2_banques/tp2/test/TestException.class new file mode 100644 index 0000000..72f7a6d Binary files /dev/null and b/tp2_banques/tp2/test/TestException.class differ diff --git a/tp2_banques/tp2/test/runHistoriqueTest.sh b/tp2_banques/tp2/test/runHistoriqueTest.sh new file mode 100755 index 0000000..23382d7 --- /dev/null +++ b/tp2_banques/tp2/test/runHistoriqueTest.sh @@ -0,0 +1,3 @@ +# !/bin/bash + +java -cp .:../operations_historisees/:../lib/junit-4.12.jar:../lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore BanqueTest CompteEpargneTest CompteHistoriqueTest diff --git a/tp2_banques/tp2/test/runTest.sh b/tp2_banques/tp2/test/runTest.sh new file mode 100755 index 0000000..0d826e5 --- /dev/null +++ b/tp2_banques/tp2/test/runTest.sh @@ -0,0 +1,4 @@ +# !/bin/bash + +java -cp .:../comptes:../lib/junit-4.12.jar:../lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore CompteTest BanqueTest CompteEpargneTest + diff --git a/tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.class b/tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.class new file mode 100644 index 0000000..5328658 Binary files /dev/null and b/tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.class differ diff --git a/tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.java b/tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.java new file mode 100644 index 0000000..7d6c60a --- /dev/null +++ b/tp3_polymorph/tp3/arithmetic/ProgressionArithmetique.java @@ -0,0 +1,65 @@ +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 "+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/tp3_polymorph/tp3/geometric/ProgressionGeometrique.class b/tp3_polymorph/tp3/geometric/ProgressionGeometrique.class new file mode 100644 index 0000000..e9d7ad6 Binary files /dev/null and b/tp3_polymorph/tp3/geometric/ProgressionGeometrique.class differ diff --git a/tp3_polymorph/tp3/geometric/ProgressionGeometrique.java b/tp3_polymorph/tp3/geometric/ProgressionGeometrique.java new file mode 100644 index 0000000..76572ca --- /dev/null +++ b/tp3_polymorph/tp3/geometric/ProgressionGeometrique.java @@ -0,0 +1,65 @@ +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 "+pg.getTerme()); + + System.out.print("next (y/n)? "); + next = sc.next().charAt(0); + } + System.out.print("\nnb termes supplementaires? "); + pg.next(sc.nextInt()); + System.out.println("\n"+pg.toString()); + } +} diff --git a/tp3_polymorph/tp3/hierarchic/Progression.class b/tp3_polymorph/tp3/hierarchic/Progression.class new file mode 100644 index 0000000..645dddf Binary files /dev/null and b/tp3_polymorph/tp3/hierarchic/Progression.class differ diff --git a/tp3_polymorph/tp3/hierarchic/Progression.java b/tp3_polymorph/tp3/hierarchic/Progression.java new file mode 100644 index 0000000..088d59a --- /dev/null +++ b/tp3_polymorph/tp3/hierarchic/Progression.java @@ -0,0 +1,60 @@ +import java.util.*; + +public abstract class Progression{ + + ArrayList termes; + double raison; + int rang; + + + public Progression(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; + } + + + abstract void next(); + + + /** + Calcul les n prochaines itérations + */ + void next(int n){ + for(int i =0; i "+p.getTerme()); + + System.out.print("next (y/n)? "); + next = sc.next().charAt(0); + } + System.out.print("\nnb termes supplementaires? "); + p.next(sc.nextInt()); + System.out.println("\n"+p.toString()); + } + +} diff --git a/tp3_polymorph/tp3/hierarchic/TestArithmetique.class b/tp3_polymorph/tp3/hierarchic/TestArithmetique.class new file mode 100644 index 0000000..7d1af93 Binary files /dev/null and b/tp3_polymorph/tp3/hierarchic/TestArithmetique.class differ diff --git a/tp3_polymorph/tp3/hierarchic/TestGeometrique.class b/tp3_polymorph/tp3/hierarchic/TestGeometrique.class new file mode 100644 index 0000000..b2de3b6 Binary files /dev/null and b/tp3_polymorph/tp3/hierarchic/TestGeometrique.class differ diff --git a/tp3_polymorph/tp3/lib/hamcrest-core-1.3.jar b/tp3_polymorph/tp3/lib/hamcrest-core-1.3.jar new file mode 100644 index 0000000..9d5fe16 Binary files /dev/null and b/tp3_polymorph/tp3/lib/hamcrest-core-1.3.jar differ diff --git a/tp3_polymorph/tp3/lib/junit-4.12.jar b/tp3_polymorph/tp3/lib/junit-4.12.jar new file mode 100644 index 0000000..3a7fc26 Binary files /dev/null and b/tp3_polymorph/tp3/lib/junit-4.12.jar differ diff --git a/tp3_polymorph/tp3/test/ProgressionArithmetiqueTest.class b/tp3_polymorph/tp3/test/ProgressionArithmetiqueTest.class new file mode 100644 index 0000000..fa754b7 Binary files /dev/null and b/tp3_polymorph/tp3/test/ProgressionArithmetiqueTest.class differ diff --git a/tp3_polymorph/tp3/test/ProgressionGeometriqueTest.class b/tp3_polymorph/tp3/test/ProgressionGeometriqueTest.class new file mode 100644 index 0000000..bf810fc Binary files /dev/null and b/tp3_polymorph/tp3/test/ProgressionGeometriqueTest.class differ diff --git a/tp3_polymorph/tp3/test/ProgressionHierarchieTest.class b/tp3_polymorph/tp3/test/ProgressionHierarchieTest.class new file mode 100644 index 0000000..091a42f Binary files /dev/null and b/tp3_polymorph/tp3/test/ProgressionHierarchieTest.class differ diff --git a/tp3_polymorph/tp3/test/TestException.class b/tp3_polymorph/tp3/test/TestException.class new file mode 100644 index 0000000..72f7a6d Binary files /dev/null and b/tp3_polymorph/tp3/test/TestException.class differ diff --git a/tp3_polymorph/tp3/test/runHierarchieTest.sh b/tp3_polymorph/tp3/test/runHierarchieTest.sh new file mode 100755 index 0000000..d79a7e3 --- /dev/null +++ b/tp3_polymorph/tp3/test/runHierarchieTest.sh @@ -0,0 +1,3 @@ +# !/bin/bash + +java -cp .:../hierarchic:../lib/junit-4.12.jar:../lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore ProgressionArithmetiqueTest ProgressionGeometriqueTest ProgressionHierarchieTest diff --git a/tp3_polymorph/tp3/test/runTest.sh b/tp3_polymorph/tp3/test/runTest.sh new file mode 100755 index 0000000..d6db0ae --- /dev/null +++ b/tp3_polymorph/tp3/test/runTest.sh @@ -0,0 +1,4 @@ +# !/bin/bash + +java -cp .:../arithmetic:../geometric:../lib/junit-4.12.jar:../lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore ProgressionArithmetiqueTest ProgressionGeometriqueTest + -- libgit2 0.21.2