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
3 changes: 3 additions & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/Spreadsheet.class
/SpreadsheetTest.class
/Cell.class
Binary file modified bin/Spreadsheet.class
Binary file not shown.
Binary file modified bin/SpreadsheetTest.class
Binary file not shown.
18 changes: 18 additions & 0 deletions src/Cell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

public class Cell {
private String id;
private String 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;
}

}
28 changes: 20 additions & 8 deletions src/Spreadsheet.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import java.util.ArrayList;

public class Spreadsheet {

public String get(String cell) {
// to be implemented
return null;
}
private ArrayList<Cell> cells = new ArrayList<Cell>();

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

public String evaluate(String cell) {
// to be implemented
return null;

public String get(String cell) {

cell.get(id);
return cell;
}



public String evaluate(String cell) {

if (cell.substring(0).contains("[1-9]+") && (cell.substring(0).matches("[1-9]+"))){
return cell;
}
return "#Error";
}
}
21 changes: 18 additions & 3 deletions tests/SpreadsheetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,24 @@
public class SpreadsheetTest {

@Test
public void test() {
fail("Not yet implemented");
public void test_EvaluatePass() {
Spreadsheet evaluate = new Spreadsheet();
evaluate.set("A3", "5");
String result = evaluate.evaluate("A3");
assertEquals("Contains only numbers", "5", result);


}



@Test
public void test_set(){
Spreadsheet set = new Spreadsheet();
set.set("A3", "5");
String result = set.get("A3");
assertEquals("5", result);
}

}

}