diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..3e0fb27
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/src/debug/ContainerArray.java b/src/debug/ContainerArray.java
index 124ece6..984ddab 100755
--- a/src/debug/ContainerArray.java
+++ b/src/debug/ContainerArray.java
@@ -2,7 +2,7 @@
public class ContainerArray {
- private int initialCapacity = 10;
+ private int limit = 10;
private int currentSize = 0;
private Object[] internalArray;
@@ -10,12 +10,16 @@ public ContainerArray () {
this(10);
}
- public ContainerArray (int initialCapacity) {
- internalArray = new Object[initialCapacity];
+ public ContainerArray (int limit) {
+ internalArray = new Object[limit];
}
public void add (E element) {
- internalArray[currentSize++] = element;
+ if (currentSize < limit) {
+ internalArray[currentSize++] = element;
+ } else {
+ //do nothing
+ }
}
public int size () {
@@ -23,7 +27,13 @@ public int size () {
}
public void remove (E objectToRemove) {
- currentSize--;
+ int startSize = currentSize;
+ for (int i = 0; i < startSize; i++) {
+ if (internalArray[i].equals((Object) objectToRemove)){
+ internalArray[i] = null;
+ currentSize--;
+ }
+ }
}
@SuppressWarnings("unchecked")
diff --git a/src/debug/ContainerArrayTest.java b/src/debug/ContainerArrayTest.java
index c566d50..d5b9dc5 100755
--- a/src/debug/ContainerArrayTest.java
+++ b/src/debug/ContainerArrayTest.java
@@ -12,7 +12,33 @@ public class ContainerArrayTest {
public void setUp () {
myContainer = new ContainerArray<>();
}
-
+
+ @Test
+ public void testArrayBounds() {
+ for (int i = 0; i < 15; i++) {
+ myContainer.add(String.valueOf(i));
+ }
+ assertEquals("Array size", 10, myContainer.size());
+ }
+
+ @Test
+ public void testRemoveObject() {
+ myContainer.add("Alligator");
+ myContainer.add("Bear");
+ myContainer.add("Alligator");
+ myContainer.remove("Alligator");
+ assertEquals("Remove element", null, myContainer.get(0));
+ assertEquals("Remove element", null, myContainer.get(2));
+ assertEquals("Remove size", 1, myContainer.size());
+ }
+
+ @Test
+ public void testRemoveObjectNotInContainer() {
+ myContainer.add("Alligator");
+ myContainer.remove("Nothing");
+ assertEquals("Remove size", 1, myContainer.size());
+ }
+
@Test
public void testSizeChangeWithAdd () {
myContainer.add("Alligator");
diff --git a/src/tdd/Sheet.java b/src/tdd/Sheet.java
new file mode 100644
index 0000000..f3b2a5c
--- /dev/null
+++ b/src/tdd/Sheet.java
@@ -0,0 +1,35 @@
+package tdd;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Sheet {
+
+ private Map myMap;
+
+ public Sheet() {
+ myMap = new HashMap<>();
+ }
+
+ public String get(String string) {
+ String tempString = myMap.get(string);
+ try{
+ int test = Integer.parseInt(myMap.get(string).trim());
+ return String.valueOf(test);
+ } catch (Exception e){
+ if (tempString == null) {
+ return "";
+ }
+ return tempString;
+ }
+ }
+
+ public String getLiteral(String key) {
+ return myMap.get(key);
+ }
+
+ public void put(String key, String obj) {
+ myMap.put(key, obj);
+ }
+
+}
diff --git a/src/tdd/TestSheet.java b/src/tdd/TestSheet.java
new file mode 100644
index 0000000..75b5d1a
--- /dev/null
+++ b/src/tdd/TestSheet.java
@@ -0,0 +1,83 @@
+package tdd;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestSheet {
+
+ @Test
+ public void testThatCellsAreEmptyByDefault() {
+ Sheet sheet = new Sheet();
+ assertEquals("", sheet.get("A1"));
+ assertEquals("", sheet.get("ZX347"));
+ }
+
+ @Test
+ public void testThatTextCellsAreStored() {
+ Sheet sheet = new Sheet();
+ String theCell = "A21";
+
+ sheet.put(theCell, "A string");
+ assertEquals("A string", sheet.get(theCell));
+
+ sheet.put(theCell, "A different string");
+ assertEquals("A different string", sheet.get(theCell));
+
+ sheet.put(theCell, "");
+ assertEquals("", sheet.get(theCell));
+ }
+
+ @Test
+ public void testThatManyCellsExist() {
+ Sheet sheet = new Sheet();
+ sheet.put("A1", "First");
+ sheet.put("X27", "Second");
+ sheet.put("ZX901", "Third");
+
+ assertEquals("A1", "First", sheet.get("A1"));
+ assertEquals("X27", "Second", sheet.get("X27"));
+ assertEquals("ZX901", "Third", sheet.get("ZX901"));
+
+ sheet.put("A1", "Fourth");
+ assertEquals("A1 after", "Fourth", sheet.get("A1"));
+ assertEquals("X27 same", "Second", sheet.get("X27"));
+ assertEquals("ZX901 same", "Third", sheet.get("ZX901"));
+ }
+
+ @Test
+ public void testThatNumericCellsAreIdentifiedAndStored() {
+ Sheet sheet = new Sheet();
+ String theCell = "A21";
+
+ sheet.put(theCell, "X99"); // "Obvious" string
+ assertEquals("X99", sheet.get(theCell));
+
+ sheet.put(theCell, "14"); // "Obvious" number
+ assertEquals("14", sheet.get(theCell));
+
+ sheet.put(theCell, " 99 X"); // Whole string must be numeric
+ assertEquals(" 99 X", sheet.get(theCell));
+
+ sheet.put(theCell, " 1234 "); // Blanks ignored
+ assertEquals("1234", sheet.get(theCell));
+
+ sheet.put(theCell, " "); // Just a blank
+ assertEquals(" ", sheet.get(theCell));
+ }
+
+ @Test
+ public void testThatWeHaveAccessToCellLiteralValuesForEditing() {
+ Sheet sheet = new Sheet();
+ String theCell = "A21";
+
+ sheet.put(theCell, "Some string");
+ assertEquals("Some string", sheet.getLiteral(theCell));
+
+ sheet.put(theCell, " 1234 ");
+ assertEquals(" 1234 ", sheet.getLiteral(theCell));
+
+ sheet.put(theCell, "=7"); // Foreshadowing formulas:)
+ assertEquals("=7", sheet.getLiteral(theCell));
+ }
+}
diff --git a/src/voogasalad/PlayerGUI.java b/src/voogasalad/PlayerGUI.java
new file mode 100644
index 0000000..115189f
--- /dev/null
+++ b/src/voogasalad/PlayerGUI.java
@@ -0,0 +1,33 @@
+package voogasalad;
+
+import java.util.ResourceBundle;
+
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.layout.AnchorPane;
+
+public class PlayerGUI{
+ private static final double TABS_OFFSET = 32.5;
+ private static final double NEWTAB_OFFSET = 2.5;
+ private static final String GUI_RESOURCE = "GUI";
+ private int windowWidth;
+ private int windowHeight;
+ private AnchorPane myRoot;
+ private TabPane myTabs;
+ private ResourceBundle myResources;
+
+ public PlayerGUI(int windowWidth, int windowHeight) {
+ this.windowWidth = windowWidth;
+ this.windowHeight = windowHeight;
+ }
+
+ public int getWidth() {
+ return this.windowWidth;
+ }
+
+ public int getHeight() {
+ return this.windowHeight;
+ }
+}
diff --git a/src/voogasalad/TestGUI.java b/src/voogasalad/TestGUI.java
new file mode 100644
index 0000000..904f500
--- /dev/null
+++ b/src/voogasalad/TestGUI.java
@@ -0,0 +1,22 @@
+package voogasalad;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import javafx.scene.control.Button;
+
+public class TestGUI {
+
+ @Test
+ public void testWidth() {
+ PlayerGUI gui = new PlayerGUI(500, 500);
+ assertEquals("Check Width", 500, gui.getWidth());
+ }
+
+ @Test
+ public void testHeight() {
+ PlayerGUI gui = new PlayerGUI(500, 500);
+ assertEquals("Check Width", 500, gui.getHeight());
+ }
+
+}