Skip to content
90 changes: 90 additions & 0 deletions .besouro/20161006162637726/actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
FileOpenedAction 1475760397941 SpreadsheetTest.java 323 2 5 1
EditAction 1475760420015 SpreadsheetTest.java 326 2 5 1
CompilationAction 1475760420171 SpreadsheetTest.java
CompilationAction 1475760420171 SpreadsheetTest.java
UnitTestCaseAction 1475760425033 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475760425034 SpreadsheetTest.java FAIL
RefactoringAction 1475760476452 TableCell.java ADD TableCell.java CLASS
FileOpenedAction 1475760476609 TableCell.java 33 0 0 0
RefactoringAction 1475760491520 TableCell.java REMOVE TableCell.java CLASS
RefactoringAction 1475760512672 Tablecell.java ADD Tablecell.java CLASS
FileOpenedAction 1475760512792 Tablecell.java 33 0 0 0
RefactoringAction 1475760549974 Tablecell.java REMOVE Tablecell.java CLASS
RefactoringAction 1475760566738 Cell.java ADD Cell.java CLASS
FileOpenedAction 1475760566858 Cell.java 28 0 0 0
RefactoringAction 1475760581353 Spreadsheet.java ADD Cell cells FIELD
RefactoringAction 1475760630905 Cell.java ADD String id FIELD
RefactoringAction 1475760639419 Cell.java ADD String value FIELD
RefactoringAction 1475760652935 Cell.java ADD String getId() METHOD
RefactoringAction 1475760652936 Cell.java ADD void setId(String) METHOD
RefactoringAction 1475760652937 Cell.java ADD String getValue() METHOD
RefactoringAction 1475760652938 Cell.java ADD void setValue(String) METHOD
RefactoringAction 1475760792258 Cell.java REMOVE Cell.java CLASS
RefactoringAction 1475760797474 Spreadsheet.java REMOVE cells FIELD
RefactoringAction 1475761112631 Cell.java ADD Cell.java CLASS
FileOpenedAction 1475761112776 Cell.java 28 0 0 0
RefactoringAction 1475761133807 Cell.java ADD String id FIELD
RefactoringAction 1475761133808 Cell.java ADD String value FIELD
RefactoringAction 1475761157828 Cell.java ADD String getId() METHOD
RefactoringAction 1475761157829 Cell.java ADD void setId(String) METHOD
RefactoringAction 1475761157829 Cell.java ADD String getValue() METHOD
RefactoringAction 1475761157830 Cell.java ADD void setValue(String) METHOD
EditAction 1475761180142 Cell.java 291 4 4 0
RefactoringAction 1475761190050 Spreadsheet.java ADD Cell cells FIELD
RefactoringAction 1475761201096 Spreadsheet.java ADD void init FIELD
RefactoringAction 1475761204609 Spreadsheet.java RENAME init=>void init() METHOD
RefactoringAction 1475761239195 Spreadsheet.java REMOVE init() METHOD
RefactoringAction 1475761291168 Spreadsheet.java ADD import java.util.ArrayList IMPORT
CompilationAction 1475761340878 SpreadsheetTest.java
RefactoringAction 1475761372891 SpreadsheetTest.java ADD import org.junit.Before IMPORT
CompilationAction 1475761377331 SpreadsheetTest.java
RefactoringAction 1475761463921 Cell.java ADD Cell(String, String) METHOD
EditAction 1475761475432 Cell.java 396 5 6 0
EditAction 1475761616333 Spreadsheet.java 364 3 3 0
EditAction 1475761778311 Spreadsheet.java 423 3 4 0
UnitTestCaseAction 1475761782519 SpreadsheetTest.java OK
UnitTestSessionAction 1475761782520 SpreadsheetTest.java OK
RefactoringAction 1475761841966 SpreadsheetTest.java ADD void testCreateCellA1()/2 METHOD
RefactoringAction 1475761846485 SpreadsheetTest.java RENAME testCreateCellA1()/2=>void testCreateCellA1_ FIELD
EditAction 1475761865867 SpreadsheetTest.java 471 3 7 2
UnitTestCaseAction 1475761868322 SpreadsheetTest.java OK
UnitTestSessionAction 1475761868322 SpreadsheetTest.java OK
RefactoringAction 1475761914545 SpreadsheetTest.java ADD void testCreateCellA1_minus1()/2 METHOD
RefactoringAction 1475761919073 SpreadsheetTest.java RENAME testCreateCellA1_minus1()/2=>void testCreateCellA1_5() METHOD
RefactoringAction 1475761920086 SpreadsheetTest.java RENAME testCreateCellA1_5()=>void testCreateCellA1_5A() METHOD
EditAction 1475761995345 SpreadsheetTest.java 610 4 10 3
EditAction 1475762016230 SpreadsheetTest.java 619 4 10 3
UnitTestCaseAction 1475762018134 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475762018135 SpreadsheetTest.java FAIL
EditAction 1475762935482 Spreadsheet.java 621 3 7 0
UnitTestCaseAction 1475762937427 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475762937428 SpreadsheetTest.java FAIL
EditAction 1475763226289 Spreadsheet.java 674 3 7 0
UnitTestCaseAction 1475763229457 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475763229457 SpreadsheetTest.java FAIL
EditAction 1475763312214 Spreadsheet.java 710 3 7 0
UnitTestCaseAction 1475763314092 SpreadsheetTest.java OK
UnitTestSessionAction 1475763314092 SpreadsheetTest.java OK
RefactoringAction 1475763444823 SpreadsheetTest.java ADD void set() METHOD
RefactoringAction 1475763450339 SpreadsheetTest.java ADD void testCreateCellA1_5A()/2 METHOD
RefactoringAction 1475763505465 SpreadsheetTest.java RENAME testCreateCellA1_5A()/2=>void testCreateCellA1astring() METHOD
RefactoringAction 1475763513478 SpreadsheetTest.java REMOVE set() METHOD
EditAction 1475763515350 SpreadsheetTest.java 776 5 13 4
UnitTestCaseAction 1475763517210 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475763517210 SpreadsheetTest.java FAIL
EditAction 1475764116999 Spreadsheet.java 936 3 7 0
UnitTestCaseAction 1475764119390 SpreadsheetTest.java OK
UnitTestSessionAction 1475764119390 SpreadsheetTest.java OK
RefactoringAction 1475764135540 SpreadsheetTest.java ADD void testCreateCellA1astring()/2 METHOD
RefactoringAction 1475764139052 SpreadsheetTest.java RENAME testCreateCellA1astring()/2=>void testCreateCellA1astringW() METHOD
RefactoringAction 1475764140064 SpreadsheetTest.java RENAME testCreateCellA1astringW()=>void testCreateCellA1astringWith() METHOD
RefactoringAction 1475764141075 SpreadsheetTest.java RENAME testCreateCellA1astringWith()=>void testCreateCellA1astringWithBAd() METHOD
RefactoringAction 1475764144589 SpreadsheetTest.java RENAME testCreateCellA1astringWithBAd()=>void testCreateCellA1astringWithBadFormat() METHOD
EditAction 1475764160091 SpreadsheetTest.java 943 6 16 5
UnitTestCaseAction 1475764163364 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475764163364 SpreadsheetTest.java FAIL
EditAction 1475764189020 Spreadsheet.java 965 3 7 0
CompilationAction 1475764189298 Spreadsheet.java
CompilationAction 1475764204616 Spreadsheet.java
UnitTestCaseAction 1475764206957 SpreadsheetTest.java OK
UnitTestSessionAction 1475764206957 SpreadsheetTest.java OK
52 changes: 52 additions & 0 deletions .besouro/20161006162637726/besouroEpisodes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
1475761782520 refactoring 3 1384 true
1475761782521 refactoring 3 1384 true
1475761782522 refactoring 3 1384 true
1475761782523 refactoring 3 1384 true
1475761782524 refactoring 3 1384 true
1475761782525 refactoring 3 1384 true
1475761782526 production 1 1384 false
1475761782527 production 3 1384 false
1475761782528 refactoring 3 1384 true
1475761782529 refactoring 3 1384 true
1475761782530 refactoring 3 1384 true
1475761782531 refactoring 3 1384 true
1475761782532 refactoring 3 1384 true
1475761782533 refactoring 3 1384 true
1475761782534 refactoring 3 1384 true
1475761782535 refactoring 3 1384 true
1475761782536 refactoring 3 1384 true
1475761782537 refactoring 3 1384 true
1475761782538 refactoring 3 1384 true
1475761782539 refactoring 3 1384 true
1475761782540 refactoring 3 1384 true
1475761782541 refactoring 3 1384 true
1475761782542 refactoring 3 1384 true
1475761782543 refactoring 3 1384 true
1475761782544 refactoring 3 1384 true
1475761782545 refactoring 3 1384 true
1475761782546 refactoring 3 1384 true
1475761782547 refactoring 3 1384 true
1475761782548 refactoring 3 1384 true
1475761782549 refactoring 3 1384 true
1475761782550 refactoring 3 1384 true
1475761782551 refactoring 3 1384 true
1475761782552 refactoring 3 1384 true
1475761868322 test-addition 1 26 true
1475761868323 test-addition 1 26 true
1475763314092 test-first 3 1399 true
1475763314093 test-first 3 1399 true
1475763314094 test-first 3 1399 true
1475763314095 test-first 3 1399 true
1475763314096 test-first 3 1399 true
1475763314097 test-first 3 1399 true
1475763314098 test-first 3 1399 true
1475763314099 test-first 3 1399 true
1475763314100 test-first 3 1399 true
1475763314101 test-first 3 1399 true
1475763314102 test-first 3 1399 true
1475763314103 test-first 3 1399 true
1475764119390 test-first 3 674 true
1475764119391 test-first 3 674 true
1475764119392 test-first 3 674 true
1475764206957 test-first 3 71 true
1475764206958 test-first 3 71 true
Empty file.
5 changes: 5 additions & 0 deletions .besouro/20161006162637726/randomHeuristicEpisodes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1475761782520 refactoring 3 1384 true
1475761868322 test-addition 1 26 false
1475763314092 test-first 3 1399 true
1475764119390 test-first 3 674 true
1475764206957 test-first 3 71 true
Empty file.
5 changes: 5 additions & 0 deletions .besouro/20161006162637726/zorroEpisodes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1475761782520 refactoring 3 1384 true
1475761868322 test-addition 1 85 true
1475763314092 test-first 3 1445 true
1475764119390 test-first 3 805 true
1475764206957 test-first 3 87 true
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Binary file added bin/Cell.class
Binary file not shown.
Binary file modified bin/Spreadsheet.class
Binary file not shown.
Binary file modified bin/SpreadsheetTest.class
Binary file not shown.
30 changes: 30 additions & 0 deletions src/Cell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

public class Cell {
private String id;
private String value;



public Cell(String id, String value) {
this.id = id;
this.value = value;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}


}
144 changes: 139 additions & 5 deletions src/Spreadsheet.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,152 @@
import java.util.ArrayList;

public class Spreadsheet {

private ArrayList<Cell> cells = new ArrayList<Cell>();
private ArrayList<String> circularReferences = new ArrayList<String>();


public String get(String cell) {
// to be implemented
for(Cell c: cells) {
if(cell.equals(c.getId()))
return c.getValue();
}
return null;
}

public void set(String cell, String value) {
// to be implemented
cells.add(new Cell(cell, value));
}

public String evaluate(String cell) {
// to be implemented
return null;
String value = get(cell);
char c = value.charAt(0);

if(Character.isDigit(c) || c =='-') {
return dealWithNumbers(value);
}

else if(c== '=') {
StringBuilder sb = new StringBuilder(value);
sb.deleteCharAt(0);
if(isAValidString(sb.toString(), sb.charAt(0))) {
return dealWithStrings(sb.toString());
}

else if(Character.isDigit(sb.charAt(0)) || sb.charAt(0) =='-') {
return dealWithNumbers(sb.toString());
}

//definition of cell #ID? Uppercase A-Z, number
else if(Character.isUpperCase(sb.charAt(0)) && Character.isDigit(sb.charAt(1)) && 2 == sb.length()) {
String cellName = sb.toString();
if(circularReferences.contains(cellName)){
return "#Circular";
}
else {
circularReferences.add(cellName);
return evaluate(cellName);
}
}

else
return "#Error";
}

else {
if(isAValidString(value, c)) {
return dealWithStrings(value);
}
else
return "#Error";
}
}




public String dealWithStrings(String input) {
StringBuilder sb = new StringBuilder(input);
sb.deleteCharAt(0);
sb.deleteCharAt(sb.length()-1);
return sb.toString();
}




public String dealWithNumbers(String input) {
String value = input;
int counter = 0;
for(char ch: value.toCharArray()){
if(ch == '-' && counter == 0) {

}
else if(Character.isDigit(ch) || ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '%') {

}
else
return "#Error";
counter++;
}

ArrayList<Integer> values = new ArrayList<Integer>();
ArrayList<Character> operations = new ArrayList<Character>();

int result = 0;
for (int i=0; i < value.length(); i++) {
char c = value.charAt(i);
if (Character.isDigit(c)) {
result = result*10 + Character.getNumericValue(c);
if(i == value.length()-1)
values.add(result);
}
else {
values.add(result);
operations.add(c);
result = 0;
}

}

int calculated = 0;
int operationCounter = -1;
for(int v : values) {
if(operationCounter == -1) {
calculated = v;
}
else {
char c = operations.get(operationCounter);
switch(c) {
case '+' :
calculated += v;
break;
case '-' :
calculated -= v;
break;
case '*' :
calculated = calculated * v;
break;
case '/' :
calculated = calculated / v;
break;
case '%' :
calculated = calculated % v;
break;
}
}
operationCounter++;
}
value = "" + calculated;
return value;
}



public boolean isAValidString(String testable, char first) {
if(first == '\'' && testable.substring(testable.length() - 1).equals("'")) {
return true;
}
return false;
}

}
Loading