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
34 changes: 29 additions & 5 deletions src/Spreadsheet.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
import java.util.Hashtable;

public class Spreadsheet {
Hashtable<String, String> cellsStrings = new Hashtable<String, String>();
Hashtable<String, Integer> cellsIntegers = new Hashtable<String, Integer>();


public String get(String cell) {
// to be implemented
return null;
public void get(String cell){
if(cellsStrings.get(cell) != null){
this.getStrings(cell);
}else{
this.getnumbers(cell);
}

}

public String getStrings(String cell){
return cellsStrings.get(cell);
}

public int getnumbers(String cell){
int convert = Integer.parseInt(cell);
return convert;
}

public void set(String cell, String value) {
// to be implemented

try{
int cells = Integer.parseInt(value);
cellsIntegers.put(cell, new Integer(value));
}catch(Exception e){
cellsStrings.put(cell, new String(value));
}

}

public String evaluate(String cell) {
// to be implemented

return null;
}

Expand Down
8 changes: 6 additions & 2 deletions tests/SpreadsheetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
public class SpreadsheetTest {

@Test
public void test() {
fail("Not yet implemented");
public void testadd_getvalue() {

Spreadsheet S = new Spreadsheet();
S.set("A1", "3");

assertEquals(3, S.get("A1"));

}

Expand Down