Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .besouro/20161006143126290/actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
FileOpenedAction 1475753486599 Spreadsheet.java 264 3 2 0
RefactoringAction 1475753561287 Cell.java ADD Cell.java CLASS
FileOpenedAction 1475753561425 Cell.java 28 0 0 0
RefactoringAction 1475753582508 Cell.java ADD String cell FIELD
RefactoringAction 1475753590552 Cell.java ADD String v FIELD
RefactoringAction 1475753593063 Cell.java RENAME v=>String value FIELD
RefactoringAction 1475753614630 Cell.java ADD String getValue FIELD
RefactoringAction 1475753617647 Cell.java RENAME getValue=>String getValue() METHOD
RefactoringAction 1475753632709 Cell.java RENAME getValue()=>String getValue(String) METHOD
RefactoringAction 1475753640743 Cell.java RENAME getValue(String)=>String getValue() METHOD
RefactoringAction 1475753708248 Spreadsheet.java ADD Object getCell() METHOD
RefactoringAction 1475753779383 Spreadsheet.java ADD List<Cell> Spre FIELD
RefactoringAction 1475753781410 Spreadsheet.java RENAME Spre=>List<Cell> Spread FIELD
RefactoringAction 1475753782932 Spreadsheet.java RENAME Spread=>List<Cell> Spreadsheet FIELD
RefactoringAction 1475753804526 Spreadsheet.java REMOVE Spreadsheet FIELD
RefactoringAction 1475753913581 Cell.java RENAME cell=>String name FIELD
RefactoringAction 1475753965624 Spreadsheet.java ADD List<Cell> Spread FIELD
RefactoringAction 1475753973142 Spreadsheet.java RENAME Spread=>List<Cell> Spreadsheet FIELD
RefactoringAction 1475754079281 Spreadsheet.java REMOVE Spreadsheet FIELD
RefactoringAction 1475754092817 Spreadsheet.java ADD Cell FIELD
RefactoringAction 1475754096335 Spreadsheet.java RENAME Sprea=>Cell FIELD
RefactoringAction 1475754200161 SpreadsheetTest.java ADD void GetCell FIELD
RefactoringAction 1475754202175 SpreadsheetTest.java RENAME GetCell=>void GetCellValue FIELD
RefactoringAction 1475754206718 SpreadsheetTest.java RENAME GetCellValue=>void GetCellValue8 FIELD
RefactoringAction 1475754208233 SpreadsheetTest.java RENAME GetCellValue8=>void GetCellValue() METHOD
EditAction 1475754300743 Spreadsheet.java 351 4 3 0
CompilationAction 1475754302535 Spreadsheet.java
EditAction 1475754302593 SpreadsheetTest.java 285 2 4 1
EditAction 1475754304288 Cell.java 127 1 1 0
UnitTestCaseAction 1475754306313 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475754306314 SpreadsheetTest.java FAIL
EditAction 1475754328894 SpreadsheetTest.java 287 2 4 1
UnitTestCaseAction 1475754330516 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475754330517 SpreadsheetTest.java FAIL
RefactoringAction 1475754412192 SpreadsheetTest.java ADD void SetCellValue FIELD
RefactoringAction 1475754413708 SpreadsheetTest.java RENAME SetCellValue=>void SetCellValue() METHOD
RefactoringAction 1475754434320 SpreadsheetTest.java ADD Cell Cell FIELD
RefactoringAction 1475754497755 Cell.java ADD void setValue(String) METHOD
EditAction 1475754526818 SpreadsheetTest.java 390 3 5 2
CompilationAction 1475754528803 SpreadsheetTest.java
EditAction 1475754528868 Cell.java 199 2 2 0
UnitTestCaseAction 1475754531050 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475754531051 SpreadsheetTest.java FAIL
RefactoringAction 1475754550233 SpreadsheetTest.java ADD void New FIELD
RefactoringAction 1475754551748 SpreadsheetTest.java RENAME New=>void NewCell FIELD
RefactoringAction 1475754553763 SpreadsheetTest.java RENAME NewCell=>void NewCell() METHOD
RefactoringAction 1475754644460 SpreadsheetTest.java ADD Spreadsheet Spreadsheet FIELD
EditAction 1475754740004 SpreadsheetTest.java 551 4 7 3
UnitTestCaseAction 1475754742686 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475754742687 SpreadsheetTest.java FAIL
RefactoringAction 1475754784774 Cell.java ADD void ne FIELD
RefactoringAction 1475754786287 Cell.java RENAME ne=>void newCell FIELD
RefactoringAction 1475754788300 Cell.java RENAME newCell=>void newCell() METHOD
RefactoringAction 1475754792320 Cell.java RENAME newCell()=>void newCell FIELD
RefactoringAction 1475754793332 Cell.java RENAME newCell=>void newCell() METHOD
RefactoringAction 1475754807871 Cell.java RENAME newCell()=>void newCell(String) METHOD
RefactoringAction 1475754810881 Cell.java RENAME newCell(String)=>void newCell(String, String) METHOD
RefactoringAction 1475755044498 Cell.java RENAME newCell(String, String)=>Cell(String, String) METHOD
RefactoringAction 1475755102839 Spreadsheet.java ADD Spreadsheet(String, String) METHOD
RefactoringAction 1475755263059 Spreadsheet.java REMOVE Spreadsheet(String, String) METHOD
RefactoringAction 1475755322743 Spreadsheet.java ADD import java.lang.reflect.Array IMPORT
RefactoringAction 1475755335682 Spreadsheet.java REMOVE Spreadsheet FIELD
RefactoringAction 1475755364696 Spreadsheet.java ADD List<Cell> Spreadsheet FIELD
RefactoringAction 1475755436405 Spreadsheet.java ADD import java.util.ArrayList IMPORT
RefactoringAction 1475755440974 Spreadsheet.java ADD import java.util.List IMPORT
RefactoringAction 1475755490824 Spreadsheet.java RENAME Spreadsheet=>Spreadsheet() METHOD
RefactoringAction 1475755548402 Spreadsheet.java ADD import Cell IMPORT
RefactoringAction 1475755563420 Spreadsheet.java REMOVE import Cell IMPORT
RefactoringAction 1475755652485 Spreadsheet.java ADD List<Cell> Spreadsheet FIELD
RefactoringAction 1475755843838 Spreadsheet.java RENAME getCell()=>int index FIELD
RefactoringAction 1475755845857 Spreadsheet.java REMOVE index FIELD
EditAction 1475755909629 Spreadsheet.java 545 4 5 0
CompilationAction 1475755911709 Spreadsheet.java
CompilationAction 1475755911710 Spreadsheet.java
EditAction 1475755911751 Cell.java 261 3 2 0
CompilationAction 1475755913799 SpreadsheetTest.java
UnitTestCaseAction 1475755916384 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475755916385 SpreadsheetTest.java FAIL
RefactoringAction 1475755930139 Cell.java ADD Cell() METHOD
EditAction 1475755942680 Cell.java 282 4 2 0
UnitTestCaseAction 1475755944895 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475755944896 SpreadsheetTest.java FAIL
EditAction 1475756112351 Spreadsheet.java 541 4 5 0
UnitTestCaseAction 1475756114742 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475756114744 SpreadsheetTest.java FAIL
EditAction 1475756149962 Spreadsheet.java 536 4 5 0
UnitTestCaseAction 1475756152345 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475756152346 SpreadsheetTest.java FAIL
RefactoringAction 1475756527233 Cell.java ADD String getName FIELD
RefactoringAction 1475756528745 Cell.java RENAME getName=>String getName() METHOD
EditAction 1475756737368 Spreadsheet.java 618 4 7 0
CompilationAction 1475756739337 Spreadsheet.java
EditAction 1475756739387 SpreadsheetTest.java 557 4 7 3
EditAction 1475756741143 Cell.java 320 5 3 0
UnitTestCaseAction 1475756742921 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475756742922 SpreadsheetTest.java FAIL
RefactoringAction 1475756881189 Spreadsheet.java REMOVE Spreadsheet() METHOD
UnitTestCaseAction 1475756886871 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475756886872 SpreadsheetTest.java FAIL
EditAction 1475757120520 Spreadsheet.java 547 3 6 0
UnitTestCaseAction 1475757124080 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475757124081 SpreadsheetTest.java FAIL
RefactoringAction 1475757300842 Cell.java RENAME Cell(String, String)=>Cell(String) METHOD
RefactoringAction 1475757302852 Cell.java REMOVE name FIELD
RefactoringAction 1475757305362 Cell.java REMOVE getName() METHOD
RefactoringAction 1475757365407 Cell.java RENAME Cell(String)=>String name FIELD
RefactoringAction 1475758391859 SpreadsheetTest.java ADD void SetCellName() METHOD
RefactoringAction 1475758470073 Cell.java ADD void set FIELD
RefactoringAction 1475758474584 Cell.java RENAME set=>void setName FIELD
RefactoringAction 1475758478095 Cell.java RENAME setName=>void setName(String) METHOD
EditAction 1475758529647 Spreadsheet.java 547 3 6 0
EditAction 1475758531710 SpreadsheetTest.java 648 5 9 4
EditAction 1475758533731 Cell.java 373 5 5 0
UnitTestCaseAction 1475758536229 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475758536230 SpreadsheetTest.java FAIL
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
34 changes: 34 additions & 0 deletions .besouro/20161006155705116/actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FileOpenedAction 1475758625332 SpreadsheetTest.java 619 5 8 4
EditAction 1475758663153 SpreadsheetTest.java 648 5 9 4
UnitTestCaseAction 1475758667052 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475758667055 SpreadsheetTest.java FAIL
FileOpenedAction 1475758678964 Spreadsheet.java 547 3 6 0
RefactoringAction 1475759528049 SpreadsheetTest.java ADD void GetCell FIELD
RefactoringAction 1475759531075 SpreadsheetTest.java RENAME GetCell=>void GetCellValue FIELD
RefactoringAction 1475759533099 SpreadsheetTest.java RENAME GetCellValue=>void GetCellValue_ FIELD
RefactoringAction 1475759534620 SpreadsheetTest.java RENAME GetCellValue_=>void GetCellValue_INT FIELD
RefactoringAction 1475759535647 SpreadsheetTest.java RENAME GetCellValue_INT=>void GetCellValue_INT() METHOD
EditAction 1475759575219 SpreadsheetTest.java 749 6 11 5
UnitTestCaseAction 1475759577530 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475759577531 SpreadsheetTest.java FAIL
EditAction 1475760534654 Spreadsheet.java 547 3 6 0
EditAction 1475760537538 Cell.java 446 5 5 0
CompilationAction 1475760539675 Cell.java
UnitTestCaseAction 1475760545107 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475760545108 SpreadsheetTest.java FAIL
UnitTestCaseAction 1475760786374 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475760786375 SpreadsheetTest.java FAIL
RefactoringAction 1475761764728 Cell.java ADD void isNaN() METHOD
RefactoringAction 1475761766744 Cell.java REMOVE isNaN() METHOD
EditAction 1475762182258 Cell.java 471 5 5 0
CompilationAction 1475762184385 Cell.java
UnitTestCaseAction 1475762187162 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475762187163 SpreadsheetTest.java FAIL
UnitTestCaseAction 1475762198862 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475762198863 SpreadsheetTest.java FAIL
EditAction 1475762220081 SpreadsheetTest.java 743 6 11 5
UnitTestCaseAction 1475762222409 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475762222410 SpreadsheetTest.java FAIL
EditAction 1475762240048 SpreadsheetTest.java 745 6 11 5
UnitTestCaseAction 1475762242373 SpreadsheetTest.java FAIL
UnitTestSessionAction 1475762242374 SpreadsheetTest.java FAIL
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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.
32 changes: 32 additions & 0 deletions src/Cell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

public class Cell {
public String name;
public String value;


public String getValue(){
return value;
}





public void setValue(String value) {

this.value=value;

}

public void setName(String name){
this.name=name;
}


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

}
63 changes: 55 additions & 8 deletions src/Spreadsheet.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,65 @@
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;


public class Spreadsheet {


List<Cell> Spreadsheet= new ArrayList<>();

public Cell get(String cell) {
int i = 0;
int index=-1;
for (i=0;i<Spreadsheet.size();i++){
if (Spreadsheet.get(i).name==cell){index=i;}
}
if (index==-1)return null;
return Spreadsheet.get(index) ;
}

public String get(String cell) {
// to be implemented
return null;
public void set(String cell, String value) {
if (get(cell)!=null)get(cell).setValue(value);
else Spreadsheet.add(new Cell(cell, value));

}
public boolean notint(String value){
int i = 0;
for(i=0;i<value.length();i++){
if(value.charAt(i)!='0'&&value.charAt(i)!='1'&&value.charAt(i)!='2'&&value.charAt(i)!='3'&&value.charAt(i)!='4'&&value.charAt(i)!='5'&&value.charAt(i)!='6'&&value.charAt(i)!='7'&&value.charAt(i)!='8'&&value.charAt(i)!='9'){return true;}
}
return false;
}

public void set(String cell, String value) {
// to be implemented
public boolean notString(String value){
int i = 0;
int occ= 0;
for (i=0;i<value.length();i++){
if(value.charAt(i)!='0'&&value.charAt(i)!='1'&&value.charAt(i)!='2'&&value.charAt(i)!='3'&&value.charAt(i)!='4'&&value.charAt(i)!='5'&&value.charAt(i)!='6'&&value.charAt(i)!='7'&&value.charAt(i)!='8'&&value.charAt(i)!='9'){occ++;}
}
if(occ!=0&&occ!=value.length())return true;
return false;
}

public String evaluate(String cell) {
// to be implemented
return null;
public boolean WrongFormat(String value){
int i = 0;
for(i=0;i<value.length();i++){
if(value.charAt(i)=='"'||value.charAt(i)=='|'||value.charAt(i)=='&'||value.charAt(i)=='{')return true;
}
return false;
}


public Object evaluate(String cell) {
String value= get(cell).getValue();
if (value.charAt(0)=='=')value=value.substring(1);
if (get(value)!=null){ System.out.println(value);}
if (value.charAt(0)=='-'&&notint(value.substring(1))==false)return Integer.parseInt(value,10);
if (notString(value)==true||WrongFormat(value)==true)return "#Error";
if (notint(value)==true){return value;}
return Integer.parseInt(value,10);


}

}
94 changes: 90 additions & 4 deletions tests/SpreadsheetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,97 @@


public class SpreadsheetTest {

Cell Cell = new Cell();
Spreadsheet Spreadsheet = new Spreadsheet();



@Test
public void GetCellValue(){

Cell.value="a";
assertEquals("","a",Cell.getValue());
}

@Test
public void test() {
fail("Not yet implemented");
public void SetCellValue(){
Cell.setValue("2");
assertEquals("","2",Cell.value);
}

@Test
public void SetCellName(){
Cell.setName("A1");
assertEquals("","A1",Cell.name);
}


@Test
public void NewCell(){
Spreadsheet.set("A2", "1");
assertEquals("","1",Spreadsheet.get("A2").getValue());

}


@Test
public void GetCellValue_INT(){
Cell.value="1";
assertEquals("","1",Cell.getValue());
}

@Test
public void Evaluate_int(){
Spreadsheet.set("A1","3");
assertEquals("",3,Spreadsheet.evaluate("A1"));
}

@Test
public void Evaluate_negativ_int(){
Spreadsheet.set("A1","-1");
assertEquals("",-1,Spreadsheet.evaluate("A1"));
}

@Test
public void Evaluate_wrongly_formated(){
Spreadsheet.set("A1","5A");
assertEquals("","#Error",Spreadsheet.evaluate("A1"));
}

@Test
public void Evaluate_string(){
Spreadsheet.set("A1","value");
assertEquals("","value",Spreadsheet.evaluate("A1"));
}

@Test
public void Evaluate_wrong_char(){
Spreadsheet.set("A1","val|ue");
assertEquals("","#Error",Spreadsheet.evaluate("A1"));
}

@Test
public void Evaluate_equals_sign(){
Spreadsheet.set("A1","=3");
assertEquals("",3,Spreadsheet.evaluate("A1"));
}

@Test
public void Evaluate_equal_string(){
Spreadsheet.set("A1","=value");
assertEquals("","value",Spreadsheet.evaluate("A1"));
}

@Test
public void Reference(){
Spreadsheet.set("A1","value");
Spreadsheet.set("A2","=A1");
assertEquals("","value",Spreadsheet.evaluate("A2"));
}
@Test
public void Set_value(){
Spreadsheet.set("A1"," value");
Spreadsheet.set("A1","1");
assertEquals("",1,Spreadsheet.evaluate("A1"));
}

}