Commit 3ac71733c748080bcb13fd50effdae623843e80c

Authored by Remi
1 parent b50da5f5

update binary operation condition

Showing 1 changed file with 7 additions and 9 deletions   Show diff stats
src/kernel/operation/BinaryOperation.java
@@ -42,16 +42,10 @@ abstract public class BinaryOperation implements Formula, Serializable { @@ -42,16 +42,10 @@ abstract public class BinaryOperation implements Formula, Serializable {
42 42
43 @Override 43 @Override
44 public boolean createCycle(Cell cell) { 44 public boolean createCycle(Cell cell) {
45 - if (this.leftCell.containFormula() && !this.rightCell.containFormula())  
46 - return this.leftCell.getFormula().createCycle(cell); 45 + if (this.createCycleWith(this.leftCell, cell) || this.createCycleWith(this.rightCell, cell))
  46 + return true;
47 47
48 - if (!this.leftCell.containFormula() && this.rightCell.containFormula())  
49 - return this.rightCell.getFormula().createCycle(cell);  
50 -  
51 - if (this.leftCell.containFormula() && this.rightCell.containFormula())  
52 - return this.leftCell.getFormula().createCycle(cell) && this.rightCell.getFormula().createCycle(cell);  
53 -  
54 - return (cell.getId().equals(this.rightCell.getId()) || cell.getId().equals(this.leftCell.getId())); 48 + return this.rightCell.equals(cell) || this.leftCell.equals(cell);
55 } 49 }
56 50
57 @Override 51 @Override
@@ -62,4 +56,8 @@ abstract public class BinaryOperation implements Formula, Serializable { @@ -62,4 +56,8 @@ abstract public class BinaryOperation implements Formula, Serializable {
62 56
63 return cells; 57 return cells;
64 } 58 }
  59 +
  60 + private boolean createCycleWith(Cell cell, Cell current) {
  61 + return cell.containFormula() && cell.getFormula().createCycle(current);
  62 + }
65 } 63 }