Blame view

src/app/Application.java 2.12 KB
18e7a394   Remi   add package
1
2
  package app;
  
94ba86ff   Remi   Auto stash before...
3
  import kernel.Cell;
2e8fbd04   Remi   global refactor
4
  import kernel.Grid;
94ba86ff   Remi   Auto stash before...
5
  import kernel.exception.CellNotFoundException;
5731029f   Remi   merge
6
  import kernel.exception.CreateCycleException;
94ba86ff   Remi   Auto stash before...
7
8
9
10
11
  import kernel.function.Average;
  import kernel.function.Sum;
  
  import java.util.ArrayList;
  import java.util.List;
18e7a394   Remi   add package
12
13
14
15
  
  public class Application {
  
      public static void main(String[] args) {
2e8fbd04   Remi   global refactor
16
          Grid grid = new Grid();
18e7a394   Remi   add package
17
  
94ba86ff   Remi   Auto stash before...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
          // Création
          System.out.println("Création de quelques cases...");
          grid.createCell("A", 1, 10.);
          grid.createCell("B", 1, 0.);
          grid.createCell("A", 2, 5.);
  
          try {
              List<Cell> sumList = new ArrayList<>();
              sumList.add(grid.getCell("A", 1));
              sumList.add(grid.getCell("A", 2));
  
              grid.createCell("A", 3, new Sum(sumList));
  
              List<Cell> averageList = new ArrayList<>();
              averageList.add(grid.getCell("A", 3));
              averageList.add(grid.getCell("B", 1));
  
              grid.createCell("B", 2, new Average(averageList));
          } catch (CellNotFoundException exception) {
              System.out.println(exception.getMessage());
5731029f   Remi   merge
38
39
          } catch (CreateCycleException exception) {
              System.out.println(exception.toString());
94ba86ff   Remi   Auto stash before...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
          }
  
          // Affichage
          List<Cell> cells = grid.getCells();
  
          System.out.println("Affichage des valeurs :");
          for (Cell cell : cells)
              System.out.println(cell.getId() + ": " + cell.getValue());
  
          System.out.println("Affichage des formules :");
          for (Cell cell : cells)
              System.out.println(cell.getId() + ": " + cell.toString());
  
          System.out.println("Affichage des formules développées :");
          for (Cell cell : cells)
              System.out.println(cell.getId() + ": " + cell.getDevelopedFormula());
5731029f   Remi   merge
56
57
58
59
60
61
62
63
64
65
66
  
          // Propagation
          try {
              grid.setValue("A", 1, 20.);
          } catch (CellNotFoundException exception) {
              System.out.println("exception");
          }
  
          System.out.println("Affichage des valeurs après modification :");
          for (Cell cell : cells)
              System.out.println(cell.getId() + ": " + cell.getValue());
18e7a394   Remi   add package
67
68
      }
  }