diff --git a/src/noyau/Addition.java b/src/noyau/Addition.java new file mode 100644 index 0000000..cc9be81 --- /dev/null +++ b/src/noyau/Addition.java @@ -0,0 +1,32 @@ +package noyau; + +import java.util.stream.Collectors; + +public class Addition extends OperationBinaire { + + Addition(Case g,Case d){ + gauche=g; + droite=d; + } + + + public double eval() { + + if (!creerCycle(gauche) && !creerCycle(droite)) + return gauche.getValeur() + droite.getValeur(); + + } + + + public String toString(){ + + return gauche.getId() +" + " + droite.getId() ; + } + + + public String getFormuleDeveloppe(){ + + return ""; + } + +} diff --git a/src/noyau/Case.java b/src/noyau/Case.java new file mode 100644 index 0000000..468a205 --- /dev/null +++ b/src/noyau/Case.java @@ -0,0 +1,13 @@ +package noyau; + +import java.util.*; + +public class Case { + + String colonne; + int ligne; + double valeur; + ArrayList utiliseDans = new ArrayList(); + boolean isFormule; + +} diff --git a/src/noyau/Division.java b/src/noyau/Division.java new file mode 100644 index 0000000..c7c8472 --- /dev/null +++ b/src/noyau/Division.java @@ -0,0 +1,34 @@ +package noyau; + +public class Division extends OperationBinaire{ + + Division(Case g,Case d){ + gauche=g; + droite=d; + } + + + + public double eval() { + + try{ + if (!creerCycle(gauche) && !creerCycle(droite)) + return gauche.getValeur() / droite.getValeur(); + } + catch(ArithmeticException ex){} + } + + + public String toString(){ + + return gauche.getId() +" / " + droite.getId() ; + } + + + + public String getFormuleDeveloppe(){ + + return ""; + } + +} diff --git a/src/noyau/Fonctions.java b/src/noyau/Fonctions.java new file mode 100644 index 0000000..41534bb --- /dev/null +++ b/src/noyau/Fonctions.java @@ -0,0 +1,25 @@ +package noyau; + +import java.util.*; + +abstract public class Fonctions extends Formule { + + ArrayList listCases = new ArrayList(); + + abstract public String getFormuleDeveloppe(); + + + + public boolean creerCycle(Case uneCase){ + + //if (!listePlage.contains(uneCase) && uneCase.utiliseDans.size()==0) + return false; + + + + + + } + + +} diff --git a/src/noyau/Formule.java b/src/noyau/Formule.java new file mode 100644 index 0000000..0f74850 --- /dev/null +++ b/src/noyau/Formule.java @@ -0,0 +1,9 @@ +package noyau; + +abstract public class Formule { + + abstract public String toString(); + abstract public double eval(); + + +} diff --git a/src/noyau/Grille.java b/src/noyau/Grille.java index 0b8c48c..bfb81ed 100644 --- a/src/noyau/Grille.java +++ b/src/noyau/Grille.java @@ -1,4 +1,5 @@ package noyau; public class Grille { + } diff --git a/src/noyau/Moyenne.java b/src/noyau/Moyenne.java new file mode 100644 index 0000000..17d0fb6 --- /dev/null +++ b/src/noyau/Moyenne.java @@ -0,0 +1,33 @@ +package noyau; + +import java.util.stream.Collectors; + +public class Moyenne extends Fonctions{ + + + public String toString(){ + + return "MOYENNE(" + listCases.stream() + .map( n -> n.getId() ) + .collect( Collectors.joining( "," ) ) + +")"; + } + + public String getFormuleDeveloppe(){ + + return ""; + } + + public double eval() { + + double val=0; + + try{ + for(int i=0; i n.getId() ) + .collect( Collectors.joining( "," ) ) + +")"; + } + + public String getFormuleDeveloppe(){ + + return ""; + } + + public double eval() { + + double val=0; + + if (listCases.size() != 0) + for(int i=0; i