Commit 2e8fbd044b79097eb5db572148a90e6a9f1d7e27
1 parent
4fe45579
global refactor
Showing
27 changed files
with
266 additions
and
353 deletions
Show diff stats
.Rhistory deleted
rapport.md
@@ -4,10 +4,10 @@ | @@ -4,10 +4,10 @@ | ||
4 | 4 | ||
5 | Le but du projet est de réaliser un tableur "basique" mais facilement | 5 | Le but du projet est de réaliser un tableur "basique" mais facilement |
6 | extensible, l'application sera divisée en 2 parties : | 6 | extensible, l'application sera divisée en 2 parties : |
7 | -* le noyau | 7 | +* le kernel |
8 | * la partie graphique | 8 | * la partie graphique |
9 | 9 | ||
10 | -Le noyau s'occupera de toutes les opérations de notre grille, les cases | 10 | +Le kernel s'occupera de toutes les opérations de notre grid, les cases |
11 | ne pourront contenir que des réels ou des formules(opération binaire ou | 11 | ne pourront contenir que des réels ou des formules(opération binaire ou |
12 | des fonctions acceptant des plages de cases). | 12 | des fonctions acceptant des plages de cases). |
13 | 13 | ||
@@ -21,7 +21,7 @@ abstraites sont en italique : | @@ -21,7 +21,7 @@ abstraites sont en italique : | ||
21 | 21 | ||
22 | ### PSEUDO-JAVA CREATION GRILLE,CASES | 22 | ### PSEUDO-JAVA CREATION GRILLE,CASES |
23 | 23 | ||
24 | -Voici un exemple de création d'une grille et de l'ajout / modification / | 24 | +Voici un exemple de création d'une grid et de l'ajout / modification / |
25 | affichage de plusieurs types de case : | 25 | affichage de plusieurs types de case : |
26 | 26 | ||
27 | ```java | 27 | ```java |
@@ -54,7 +54,7 @@ class Application { | @@ -54,7 +54,7 @@ class Application { | ||
54 | g.getValeur("a",1); //Affichera 100.0 | 54 | g.getValeur("a",1); //Affichera 100.0 |
55 | g.getValeur("a",4); //Affichera (100+50+150)=100 | 55 | g.getValeur("a",4); //Affichera (100+50+150)=100 |
56 | g.getFormuleAsString("b",2); //Affichera MOYENNE(a4,a2,a3) | 56 | g.getFormuleAsString("b",2); //Affichera MOYENNE(a4,a2,a3) |
57 | - g.getFormuleDeveloppe("b",2); //Affichera MOYENNE(Somme(a1,a2,a3),a2,(a1+a2)) | 57 | + g.getFormuleDeveloppe("b",2); Sum |
58 | } | 58 | } |
59 | } | 59 | } |
60 | ``` | 60 | ``` |
@@ -62,7 +62,7 @@ class Application { | @@ -62,7 +62,7 @@ class Application { | ||
62 | ### CHOIX STRUCTURE DE DONNÉES | 62 | ### CHOIX STRUCTURE DE DONNÉES |
63 | 63 | ||
64 | Nous devons choisir une structure de donnée pour stocker les cases dans | 64 | Nous devons choisir une structure de donnée pour stocker les cases dans |
65 | -notre grille, nous savons déjà que nous allons utiliser ne collection | 65 | +notre grid, nous savons déjà que nous allons utiliser ne collection |
66 | pour les stocker,voici celles que nous connaissons: | 66 | pour les stocker,voici celles que nous connaissons: |
67 | - des tableaux | 67 | - des tableaux |
68 | - des listes | 68 | - des listes |
@@ -70,7 +70,7 @@ pour les stocker,voici celles que nous connaissons: | @@ -70,7 +70,7 @@ pour les stocker,voici celles que nous connaissons: | ||
70 | - des sets | 70 | - des sets |
71 | 71 | ||
72 | D'après le schéma UML ci-dessus, nous allons donc utiliser une `HashMap` | 72 | D'après le schéma UML ci-dessus, nous allons donc utiliser une `HashMap` |
73 | -pour stocker les cases de notre grille : | 73 | +pour stocker les cases de notre grid : |
74 | * Pour rechercher une case et, effectuer des opérations dessus ce sera | 74 | * Pour rechercher une case et, effectuer des opérations dessus ce sera |
75 | plus facile, la clé de la Map sera une chaine de caractère (String) qui | 75 | plus facile, la clé de la Map sera une chaine de caractère (String) qui |
76 | représente la coordonnée de cette case (c'est-à-dire la concaténation | 76 | représente la coordonnée de cette case (c'est-à-dire la concaténation |
@@ -180,12 +180,12 @@ class Case{ | @@ -180,12 +180,12 @@ class Case{ | ||
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | -// Exemple pour Moyenne | 183 | +Average |
184 | class Moyenne { | 184 | class Moyenne { |
185 | List<Case> listCases = new ArrayList<Case>(); | 185 | List<Case> listCases = new ArrayList<Case>(); |
186 | 186 | ||
187 | String getFormuleDeveloppe() { | 187 | String getFormuleDeveloppe() { |
188 | - return "Moyenne(" + listCases.stream().map(c -> c.getFormuleDeveloppe()).collect((Collectors).joining(", ")) + ")"; | 188 | + return Average + listCases.stream().map(c -> c.getFormuleDeveloppe()).collect((Collectors).joining(", ")) + ")"; |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
@@ -354,7 +354,7 @@ class Case { | @@ -354,7 +354,7 @@ class Case { | ||
354 | } | 354 | } |
355 | } | 355 | } |
356 | 356 | ||
357 | -// Exemple pour OperationBinaire | 357 | +BinaryOperation |
358 | class OperationBinaire { | 358 | class OperationBinaire { |
359 | Case gauche; | 359 | Case gauche; |
360 | Case droite; | 360 | Case droite; |
src/app/Application.java
1 | package app; | 1 | package app; |
2 | 2 | ||
3 | -import noyau.Grille; | 3 | +import kernel.Grid; |
4 | 4 | ||
5 | public class Application { | 5 | public class Application { |
6 | 6 | ||
7 | public static void main(String[] args) { | 7 | public static void main(String[] args) { |
8 | - Grille grille = new Grille(); | 8 | + Grid grid = new Grid(); |
9 | 9 | ||
10 | System.out.println("Hello world!"); | 10 | System.out.println("Hello world!"); |
11 | } | 11 | } |
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +package kernel; | ||
2 | + | ||
3 | +abstract public class BinaryOperation extends Formula { | ||
4 | + | ||
5 | + protected Cell leftCell; | ||
6 | + protected Cell rightCell; | ||
7 | + protected String operator; | ||
8 | + | ||
9 | + public BinaryOperation(Cell leftCell, Cell rightCell) { | ||
10 | + this.leftCell = leftCell; | ||
11 | + this.rightCell = rightCell; | ||
12 | + } | ||
13 | + | ||
14 | + public String getDevelopedFormula() { | ||
15 | + return this.leftCell.getDevelopedFormula() + " " + this.operator + " " + this.rightCell.getDevelopedFormula(); | ||
16 | + } | ||
17 | + | ||
18 | + public String toString() { | ||
19 | + return this.leftCell.toString() + " " + this.operator + " " + this.rightCell.toString(); | ||
20 | + } | ||
21 | + | ||
22 | + abstract public Double eval(); | ||
23 | + | ||
24 | + public Boolean createCycle(Cell cell) { | ||
25 | + if (this.leftCell.containFormula() && !this.rightCell.containFormula()) | ||
26 | + return this.leftCell.getFormula().createCycle(cell); | ||
27 | + else { | ||
28 | + if (!this.leftCell.containFormula() && this.rightCell.containFormula()) | ||
29 | + return this.rightCell.getFormula().createCycle(cell); | ||
30 | + else { | ||
31 | + if (this.leftCell.containFormula() && this.rightCell.containFormula()) | ||
32 | + return this.leftCell.getFormula().createCycle(cell) && this.rightCell.getFormula().createCycle(cell); | ||
33 | + else { | ||
34 | + return (cell.getId().equals(this.rightCell.getId()) || cell.getId().equals(this.leftCell.getId())); | ||
35 | + } | ||
36 | + } | ||
37 | + | ||
38 | + } | ||
39 | + } | ||
40 | +} |
src/noyau/Case.java renamed to src/kernel/Cell.java
1 | -package noyau; | 1 | +package kernel; |
2 | 2 | ||
3 | import java.util.ArrayList; | 3 | import java.util.ArrayList; |
4 | import java.util.List; | 4 | import java.util.List; |
5 | 5 | ||
6 | -public class Case { | 6 | +public class Cell { |
7 | 7 | ||
8 | private String column; | 8 | private String column; |
9 | private Integer line; | 9 | private Integer line; |
10 | private Double value; | 10 | private Double value; |
11 | - private Formule formula; | ||
12 | - private List<Case> usedIn = new ArrayList<>(); | 11 | + private Formula formula; |
12 | + private List<Cell> usedIn = new ArrayList<>(); | ||
13 | 13 | ||
14 | - public Case(String column, Integer line, Double value) { | 14 | + public Cell(String column, Integer line, Double value) { |
15 | this.column = column; | 15 | this.column = column; |
16 | this.line = line; | 16 | this.line = line; |
17 | this.value = value; | 17 | this.value = value; |
18 | } | 18 | } |
19 | 19 | ||
20 | - public Case(String column, Integer line, Formule formula) { | 20 | + public Cell(String column, Integer line, Formula formula) { |
21 | this.column = column; | 21 | this.column = column; |
22 | this.line = line; | 22 | this.line = line; |
23 | this.formula = formula; | 23 | this.formula = formula; |
24 | } | 24 | } |
25 | 25 | ||
26 | - public double getValue() { | 26 | + public Double getValue() { |
27 | return this.value; | 27 | return this.value; |
28 | } | 28 | } |
29 | - | ||
30 | - public List<Case> getUsedIn() { | ||
31 | - return this.usedIn; | ||
32 | - } | ||
33 | 29 | ||
34 | - public void setValue(Double value) { | ||
35 | - this.value = value; | ||
36 | - this.spread(); | 30 | + public Formula getFormula() { |
31 | + return this.formula; | ||
37 | } | 32 | } |
38 | 33 | ||
39 | - public void updateValue() { | ||
40 | - | 34 | + public String getDevelopedFormula() { |
35 | + return containFormula() ? this.formula.getDevelopedFormula() : this.toString(); | ||
41 | } | 36 | } |
42 | 37 | ||
43 | public String getId() { | 38 | public String getId() { |
44 | return this.column + this.line.toString(); | 39 | return this.column + this.line.toString(); |
45 | } | 40 | } |
46 | 41 | ||
47 | - public Boolean containFormula() { | ||
48 | - return this.formula != null; | 42 | + public List<Cell> getUsedIn() { |
43 | + return this.usedIn; | ||
49 | } | 44 | } |
50 | 45 | ||
51 | - | 46 | + public String toString() { |
47 | + return containFormula() ? this.formula.toString() : this.getId(); | ||
48 | + } | ||
52 | 49 | ||
53 | - public Formule getFormula() { | ||
54 | - return this.formula; | 50 | + public void updateValue() { |
51 | + this.value = this.formula.eval(); | ||
52 | + } | ||
53 | + | ||
54 | + public Boolean containFormula() { | ||
55 | + return this.formula != null; | ||
55 | } | 56 | } |
56 | 57 | ||
57 | - public void setFormula(Formule formula) { | 58 | + public void setFormula(Formula formula) { |
58 | this.formula = formula; | 59 | this.formula = formula; |
59 | this.spread(); | 60 | this.spread(); |
60 | } | 61 | } |
61 | 62 | ||
63 | + public void setValue(Double value) { | ||
64 | + this.value = value; | ||
65 | + this.spread(); | ||
66 | + } | ||
67 | + | ||
62 | private void spread() { | 68 | private void spread() { |
63 | - for (Case cell : this.usedIn) | 69 | + for (Cell cell : this.usedIn) |
64 | cell.updateValue(); | 70 | cell.updateValue(); |
65 | } | 71 | } |
66 | } | 72 | } |
src/noyau/Grille.java renamed to src/kernel/Grid.java
1 | -package noyau; | 1 | +package kernel; |
2 | 2 | ||
3 | -import noyau.exception.CellNotFoundException; | 3 | +import kernel.exception.CellNotFoundException; |
4 | 4 | ||
5 | import java.util.HashMap; | 5 | import java.util.HashMap; |
6 | import java.util.Map; | 6 | import java.util.Map; |
7 | 7 | ||
8 | -public class Grille { | 8 | +public class Grid { |
9 | 9 | ||
10 | - private Map<String, Case> cases = new HashMap<>(); | 10 | + private Map<String, Cell> cells = new HashMap<>(); |
11 | 11 | ||
12 | - public String createCase(String column, Integer line, Double value) { | 12 | + public String createCell(String column, Integer line, Double value) { |
13 | String id = this.getId(column, line); | 13 | String id = this.getId(column, line); |
14 | - Case cell = new Case(column, line, value); | 14 | + Cell cell = new Cell(column, line, value); |
15 | 15 | ||
16 | - this.cases.put(id, cell); | 16 | + this.cells.put(id, cell); |
17 | 17 | ||
18 | return id; | 18 | return id; |
19 | } | 19 | } |
20 | 20 | ||
21 | - public String createCase(String column, Integer line, Formule formula) { | 21 | + public String createCell(String column, Integer line, Formula formula) { |
22 | String id = this.getId(column, line); | 22 | String id = this.getId(column, line); |
23 | - Case cell = new Case(column, line, formula); | 23 | + Cell cell = new Cell(column, line, formula); |
24 | 24 | ||
25 | - this.cases.put(id, cell); | 25 | + this.cells.put(id, cell); |
26 | 26 | ||
27 | return id; | 27 | return id; |
28 | } | 28 | } |
29 | 29 | ||
30 | public void setValue(String column, Integer line, Double value) throws CellNotFoundException { | 30 | public void setValue(String column, Integer line, Double value) throws CellNotFoundException { |
31 | - Case cell = this.getCase(column, line); | 31 | + Cell cell = this.getCell(column, line); |
32 | 32 | ||
33 | try { | 33 | try { |
34 | cell.setValue(value); | 34 | cell.setValue(value); |
@@ -37,8 +37,8 @@ public class Grille { | @@ -37,8 +37,8 @@ public class Grille { | ||
37 | } | 37 | } |
38 | } | 38 | } |
39 | 39 | ||
40 | - public void setFormula(String column, Integer line, Formule formula) throws CellNotFoundException { | ||
41 | - Case cell = this.getCase(column, line); | 40 | + public void setFormula(String column, Integer line, Formula formula) throws CellNotFoundException { |
41 | + Cell cell = this.getCell(column, line); | ||
42 | 42 | ||
43 | try { | 43 | try { |
44 | cell.setFormula(formula); | 44 | cell.setFormula(formula); |
@@ -47,12 +47,12 @@ public class Grille { | @@ -47,12 +47,12 @@ public class Grille { | ||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | - public Case getCase(String column, Integer line) { | ||
51 | - return this.cases.get(this.getId(column, line)); | 50 | + public Cell getCell(String column, Integer line) { |
51 | + return this.cells.get(this.getId(column, line)); | ||
52 | } | 52 | } |
53 | 53 | ||
54 | - public Double getValeur(String column, Integer line) throws CellNotFoundException { | ||
55 | - Case cell = this.getCase(column, line); | 54 | + public Double getValue(String column, Integer line) throws CellNotFoundException { |
55 | + Cell cell = this.getCell(column, line); | ||
56 | 56 | ||
57 | try { | 57 | try { |
58 | return cell.getValue(); | 58 | return cell.getValue(); |
@@ -61,11 +61,11 @@ public class Grille { | @@ -61,11 +61,11 @@ public class Grille { | ||
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | - public String getFormuleAsString(String column, Integer line) throws CellNotFoundException { | ||
65 | - Case cell = this.getCase(column, line); | 64 | + public String getFormulaAsString(String column, Integer line) throws CellNotFoundException { |
65 | + Cell cell = this.getCell(column, line); | ||
66 | 66 | ||
67 | try { | 67 | try { |
68 | - return cell.getValue(); | 68 | + return cell.getFormula().toString(); |
69 | } catch (NullPointerException exception) { | 69 | } catch (NullPointerException exception) { |
70 | throw new CellNotFoundException(); | 70 | throw new CellNotFoundException(); |
71 | } | 71 | } |
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +package kernel.function; | ||
2 | + | ||
3 | +import kernel.Cell; | ||
4 | + | ||
5 | +import java.util.OptionalDouble; | ||
6 | +import java.util.stream.Collectors; | ||
7 | + | ||
8 | +public class Average extends Function { | ||
9 | + | ||
10 | + public String toString() { | ||
11 | + return "MOYENNE(" + this.listCells.stream() | ||
12 | + .map(Cell::getId) | ||
13 | + .collect(Collectors.joining(",")) | ||
14 | + + ")"; | ||
15 | + } | ||
16 | + | ||
17 | + public String getDevelopedFormula() { | ||
18 | + return "MOYENNE(" + this.listCells.stream() | ||
19 | + .map(Cell::getDevelopedFormula) | ||
20 | + .collect(Collectors.joining(",")) | ||
21 | + + ")"; | ||
22 | + } | ||
23 | + | ||
24 | + public Double eval() { | ||
25 | + OptionalDouble average = this.listCells.stream() | ||
26 | + .mapToDouble(Cell::getValue) | ||
27 | + .average(); | ||
28 | + | ||
29 | + return average.isPresent() ? average.getAsDouble() : 0.; | ||
30 | + } | ||
31 | +} |
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +package kernel.function; | ||
2 | + | ||
3 | +import kernel.Cell; | ||
4 | +import kernel.Formula; | ||
5 | + | ||
6 | +import java.util.ArrayList; | ||
7 | + | ||
8 | +abstract public class Function extends Formula { | ||
9 | + | ||
10 | + protected ArrayList<Cell> listCells = new ArrayList<>(); | ||
11 | + | ||
12 | + abstract public String getDevelopedFormula(); | ||
13 | + | ||
14 | + abstract public String toString(); | ||
15 | + | ||
16 | + abstract public Double eval(); | ||
17 | + | ||
18 | + public Boolean createCycle(Cell cell) { | ||
19 | + return this.listCells.contains(cell); | ||
20 | + } | ||
21 | +} |
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | +package kernel.function; | ||
2 | + | ||
3 | +import kernel.Cell; | ||
4 | +import kernel.function.Function; | ||
5 | + | ||
6 | +import java.util.stream.Collectors; | ||
7 | + | ||
8 | +public class Sum extends Function { | ||
9 | + | ||
10 | + public String toString() { | ||
11 | + return "SOMME(" + this.listCells.stream() | ||
12 | + .map(Cell::getId) | ||
13 | + .collect(Collectors.joining(",")) | ||
14 | + + ")"; | ||
15 | + } | ||
16 | + | ||
17 | + public String getDevelopedFormula() { | ||
18 | + return "SOMME(" + this.listCells.stream() | ||
19 | + .map(Cell::getDevelopedFormula) | ||
20 | + .collect(Collectors.joining(",")) | ||
21 | + + ")"; | ||
22 | + } | ||
23 | + | ||
24 | + public Double eval() { | ||
25 | + return this.listCells.stream() | ||
26 | + .mapToDouble(Cell::getValue) | ||
27 | + .sum(); | ||
28 | + } | ||
29 | +} |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +package kernel.operation; | ||
2 | + | ||
3 | +import kernel.BinaryOperation; | ||
4 | +import kernel.Cell; | ||
5 | + | ||
6 | +public class Addition extends BinaryOperation { | ||
7 | + | ||
8 | + public Addition(Cell leftCell, Cell rightCell) { | ||
9 | + super(leftCell, rightCell); | ||
10 | + this.operator = "+"; | ||
11 | + } | ||
12 | + | ||
13 | + public Double eval() { | ||
14 | + return this.leftCell.getValue() + this.rightCell.getValue(); | ||
15 | + } | ||
16 | +} |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +package kernel.operation; | ||
2 | + | ||
3 | +import kernel.BinaryOperation; | ||
4 | +import kernel.Cell; | ||
5 | + | ||
6 | +public class Division extends BinaryOperation { | ||
7 | + | ||
8 | + public Division(Cell leftCell, Cell rightCell) { | ||
9 | + super(leftCell, rightCell); | ||
10 | + this.operator = "/"; | ||
11 | + } | ||
12 | + | ||
13 | + public Double eval() { | ||
14 | + return this.leftCell.getValue() / this.rightCell.getValue(); | ||
15 | + } | ||
16 | +} |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +package kernel.operation; | ||
2 | + | ||
3 | +import kernel.BinaryOperation; | ||
4 | +import kernel.Cell; | ||
5 | + | ||
6 | +public class Multiplication extends BinaryOperation { | ||
7 | + | ||
8 | + public Multiplication(Cell leftCell, Cell rightCell) { | ||
9 | + super(leftCell, rightCell); | ||
10 | + this.operator = "*"; | ||
11 | + } | ||
12 | + | ||
13 | + public Double eval() { | ||
14 | + return this.leftCell.getValue() * this.rightCell.getValue(); | ||
15 | + } | ||
16 | +} |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +package kernel.operation; | ||
2 | + | ||
3 | +import kernel.BinaryOperation; | ||
4 | +import kernel.Cell; | ||
5 | + | ||
6 | +public class Subtraction extends BinaryOperation { | ||
7 | + | ||
8 | + public Subtraction(Cell leftCell, Cell rightCell) { | ||
9 | + super(leftCell, rightCell); | ||
10 | + this.operator = "-"; | ||
11 | + } | ||
12 | + | ||
13 | + public Double eval() { | ||
14 | + return this.leftCell.getValue() - this.rightCell.getValue(); | ||
15 | + } | ||
16 | +} |
src/noyau/Addition.java deleted
@@ -1,34 +0,0 @@ | @@ -1,34 +0,0 @@ | ||
1 | -package noyau; | ||
2 | - | ||
3 | -import java.util.stream.Collectors; | ||
4 | - | ||
5 | -public class Addition extends OperationBinaire { | ||
6 | - | ||
7 | - Addition(Case g,Case d){ | ||
8 | - gauche=g; | ||
9 | - droite=d; | ||
10 | - } | ||
11 | - | ||
12 | - | ||
13 | - public double eval() { | ||
14 | - | ||
15 | - if (!creerCycle(gauche) && !creerCycle(droite)) | ||
16 | - return (double) gauche.getValue() + droite.getValue(); | ||
17 | - else | ||
18 | - return 0; | ||
19 | - | ||
20 | - } | ||
21 | - | ||
22 | - | ||
23 | - public String toString(){ | ||
24 | - | ||
25 | - return gauche.getId() +" + " + droite.getId() ; | ||
26 | - } | ||
27 | - | ||
28 | - | ||
29 | - public String getFormuleDeveloppe(){ | ||
30 | - | ||
31 | - return ""; | ||
32 | - } | ||
33 | - | ||
34 | -} |
src/noyau/Division.java deleted
@@ -1,47 +0,0 @@ | @@ -1,47 +0,0 @@ | ||
1 | -package noyau; | ||
2 | - | ||
3 | -import noyau.exception.CellNotFoundException; | ||
4 | -import noyau.exception.DivisionByZeroException; | ||
5 | - | ||
6 | -public class Division extends OperationBinaire{ | ||
7 | - | ||
8 | - Division(Case g,Case d){ | ||
9 | - gauche=g; | ||
10 | - droite=d; | ||
11 | - } | ||
12 | - | ||
13 | - | ||
14 | - | ||
15 | - public double eval() throws DivisionByZeroException { | ||
16 | - | ||
17 | - try{ | ||
18 | - if (!creerCycle(gauche) && !creerCycle(droite)) | ||
19 | - | ||
20 | - return gauche.getValue()/droite.getValue(); | ||
21 | - else | ||
22 | - return 0; | ||
23 | - } | ||
24 | - catch(ArithmeticException ex){ | ||
25 | - throw new DivisionByZeroException(); | ||
26 | - } | ||
27 | - | ||
28 | - | ||
29 | - | ||
30 | - | ||
31 | - | ||
32 | - } | ||
33 | - | ||
34 | - | ||
35 | - public String toString(){ | ||
36 | - | ||
37 | - return gauche.getId() +" / " + droite.getId() ; | ||
38 | - } | ||
39 | - | ||
40 | - | ||
41 | - | ||
42 | - public String getFormuleDeveloppe(){ | ||
43 | - | ||
44 | - return ""; | ||
45 | - } | ||
46 | - | ||
47 | -} |
src/noyau/Fonctions.java deleted
@@ -1,25 +0,0 @@ | @@ -1,25 +0,0 @@ | ||
1 | -package noyau; | ||
2 | - | ||
3 | -import java.util.*; | ||
4 | - | ||
5 | -abstract public class Fonctions extends Formule { | ||
6 | - | ||
7 | - ArrayList<Case> listCases = new ArrayList<Case>(); | ||
8 | - | ||
9 | - abstract public String getFormuleDeveloppe(); | ||
10 | - | ||
11 | - | ||
12 | - | ||
13 | - public boolean creerCycle(Case uneCase){ | ||
14 | - | ||
15 | - return listCases.contains(uneCase); | ||
16 | - | ||
17 | - | ||
18 | - | ||
19 | - | ||
20 | - | ||
21 | - | ||
22 | - } | ||
23 | - | ||
24 | - | ||
25 | -} |
src/noyau/Formule.java deleted
@@ -1,11 +0,0 @@ | @@ -1,11 +0,0 @@ | ||
1 | -package noyau; | ||
2 | - | ||
3 | -import noyau.exception.DivisionByZeroException; | ||
4 | - | ||
5 | -abstract public class Formule { | ||
6 | - | ||
7 | - abstract public String toString(); | ||
8 | - abstract public double eval() throws DivisionByZeroException; | ||
9 | - abstract public boolean creerCycle(Case uneCase); | ||
10 | - | ||
11 | -} |
src/noyau/Moyenne.java deleted
@@ -1,35 +0,0 @@ | @@ -1,35 +0,0 @@ | ||
1 | -package noyau; | ||
2 | - | ||
3 | -import java.util.stream.Collectors; | ||
4 | - | ||
5 | -public class Moyenne extends Fonctions{ | ||
6 | - | ||
7 | - | ||
8 | - public String toString(){ | ||
9 | - | ||
10 | - return "MOYENNE(" + listCases.stream() | ||
11 | - .map( n -> n.getId() ) | ||
12 | - .collect( Collectors.joining( "," ) ) | ||
13 | - +")"; | ||
14 | - } | ||
15 | - | ||
16 | - public String getFormuleDeveloppe(){ | ||
17 | - | ||
18 | - return ""; | ||
19 | - } | ||
20 | - | ||
21 | - public double eval() { | ||
22 | - | ||
23 | - double val=0.0; | ||
24 | - | ||
25 | - try{ | ||
26 | - for(int i=0; i<listCases.size(); i++) | ||
27 | - val += listCases.get(i).getValue(); | ||
28 | - | ||
29 | - return (double)val/listCases.size(); | ||
30 | - } | ||
31 | - catch(ArithmeticException ex){ | ||
32 | - return 0.0; | ||
33 | - } | ||
34 | - } | ||
35 | -} |
src/noyau/Multiplication.java deleted
@@ -1,32 +0,0 @@ | @@ -1,32 +0,0 @@ | ||
1 | -package noyau; | ||
2 | - | ||
3 | -public class Multiplication extends OperationBinaire{ | ||
4 | - | ||
5 | - Multiplication(Case g,Case d){ | ||
6 | - gauche=g; | ||
7 | - droite=d; | ||
8 | - } | ||
9 | - | ||
10 | - | ||
11 | - public double eval() { | ||
12 | - | ||
13 | - if (!creerCycle(gauche) && !creerCycle(droite)) | ||
14 | - return gauche.getValue() * droite.getValue(); | ||
15 | - else | ||
16 | - return 0; | ||
17 | - } | ||
18 | - | ||
19 | - | ||
20 | - public String toString(){ | ||
21 | - | ||
22 | - return gauche.getId() +" * " + droite.getId() ; | ||
23 | - } | ||
24 | - | ||
25 | - | ||
26 | - | ||
27 | - public String getFormuleDeveloppe(){ | ||
28 | - | ||
29 | - return ""; | ||
30 | - } | ||
31 | - | ||
32 | -} |
src/noyau/OperationBinaire.java deleted
@@ -1,41 +0,0 @@ | @@ -1,41 +0,0 @@ | ||
1 | -package noyau; | ||
2 | - | ||
3 | - | ||
4 | -import noyau.exception.DivisionByZeroException; | ||
5 | - | ||
6 | - | ||
7 | - | ||
8 | -abstract public class OperationBinaire extends Formule { | ||
9 | - | ||
10 | - Case droite; | ||
11 | - Case gauche; | ||
12 | - | ||
13 | - abstract public String getFormuleDeveloppe(); | ||
14 | - | ||
15 | - abstract public double eval() throws DivisionByZeroException; | ||
16 | - | ||
17 | - public boolean creerCycle(Case uneCase){ | ||
18 | - | ||
19 | - | ||
20 | - if (droite.containFormula() && !gauche.containFormula()) | ||
21 | - return droite.getFormula().creerCycle(uneCase); | ||
22 | - else { | ||
23 | - if (!droite.containFormula() && gauche.containFormula()) | ||
24 | - return gauche.getFormula().creerCycle(uneCase); | ||
25 | - else{ | ||
26 | - if (droite.containFormula() && gauche.containFormula()) | ||
27 | - return gauche.getFormula().creerCycle(uneCase) && droite.getFormula().creerCycle(uneCase); | ||
28 | - else{ | ||
29 | - return (uneCase.getId()==droite.getId() || uneCase.getId()==gauche.getId()); | ||
30 | - } | ||
31 | - } | ||
32 | - | ||
33 | - } | ||
34 | - | ||
35 | - | ||
36 | - | ||
37 | - | ||
38 | - | ||
39 | - | ||
40 | - } | ||
41 | -} |
src/noyau/Somme.java deleted
@@ -1,31 +0,0 @@ | @@ -1,31 +0,0 @@ | ||
1 | -package noyau; | ||
2 | - | ||
3 | -import java.util.*; | ||
4 | -import java.util.stream.Collectors; | ||
5 | - | ||
6 | -public class Somme extends Fonctions{ | ||
7 | - | ||
8 | - public String toString(){ | ||
9 | - | ||
10 | - return "SOMME(" + listCases.stream() | ||
11 | - .map( n -> n.getId() ) | ||
12 | - .collect( Collectors.joining( "," ) ) | ||
13 | - +")"; | ||
14 | - } | ||
15 | - | ||
16 | - public String getFormuleDeveloppe(){ | ||
17 | - | ||
18 | - return ""; | ||
19 | - } | ||
20 | - | ||
21 | - public double eval() { | ||
22 | - | ||
23 | - double val=0; | ||
24 | - | ||
25 | - if (listCases.size() != 0) | ||
26 | - for(int i=0; i<listCases.size(); i++) | ||
27 | - val += listCases.get(i).getValue(); | ||
28 | - | ||
29 | - return val; | ||
30 | - } | ||
31 | -} |
src/noyau/Soustraction.java deleted
@@ -1,34 +0,0 @@ | @@ -1,34 +0,0 @@ | ||
1 | -package noyau; | ||
2 | - | ||
3 | -public class Soustraction extends OperationBinaire{ | ||
4 | - | ||
5 | - Soustraction(Case g,Case d){ | ||
6 | - gauche=g; | ||
7 | - droite=d; | ||
8 | - } | ||
9 | - | ||
10 | - | ||
11 | - | ||
12 | - public double eval() { | ||
13 | - | ||
14 | - if (!creerCycle(gauche) && !creerCycle(droite)) | ||
15 | - return gauche.getValue() - droite.getValue(); | ||
16 | - else | ||
17 | - return 0; | ||
18 | - } | ||
19 | - | ||
20 | - | ||
21 | - | ||
22 | - | ||
23 | - public String toString(){ | ||
24 | - | ||
25 | - return gauche.getId() +" - " + droite.getId() ; | ||
26 | - } | ||
27 | - | ||
28 | - | ||
29 | - public String getFormuleDeveloppe(){ | ||
30 | - | ||
31 | - return ""; | ||
32 | - } | ||
33 | - | ||
34 | -} |
src/noyau/exception/CellNotFoundException.java deleted