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..be80677 100755
--- a/src/debug/ContainerArray.java
+++ b/src/debug/ContainerArray.java
@@ -1,8 +1,10 @@
package debug;
+import java.util.Arrays;
+
public class ContainerArray {
- private int initialCapacity = 10;
+ private int limit = 10;
private int currentSize = 0;
private Object[] internalArray;
@@ -23,7 +25,23 @@ public int size () {
}
public void remove (E objectToRemove) {
- currentSize--;
+ int toBeRemoved = 0;
+
+ if (objectToRemove instanceof String) {
+ int n = 0;
+ while (internalArray[n] != null){
+ if (((String)internalArray[n]).equals((String) objectToRemove)){
+ internalArray[n] = null;
+ toBeRemoved++;
+ }
+ n++;
+ }
+ internalArray = Arrays.stream(internalArray)
+ .filter(s -> (s != null))
+ .toArray(Object[]::new);
+
+ currentSize -= toBeRemoved;
+ }
}
@SuppressWarnings("unchecked")
diff --git a/src/debug/ContainerArrayTest.java b/src/debug/ContainerArrayTest.java
index c566d50..8a56944 100755
--- a/src/debug/ContainerArrayTest.java
+++ b/src/debug/ContainerArrayTest.java
@@ -44,4 +44,19 @@ public void testObjectIsRemoved () {
myContainer.remove("Bear");
assertEquals("Remove should be same reference", alligator, myContainer.get(0));
}
+
+ /**
+ * Just wrote this one test, we understand the idea and will
+ * now go play with VoogaSalad
+ */
+ @Test
+ public void testRemovesCorrectElement(){
+ System.out.println("START");
+ String falcon = "Falcon";
+ myContainer.add("Alligator");
+ myContainer.add("Bear");
+ myContainer.add(falcon);
+ myContainer.remove("Bear");
+ assertEquals("Remove should be of correct index", falcon, myContainer.get(1));
+ }
}
diff --git a/src/tdd/Sheet.java b/src/tdd/Sheet.java
new file mode 100644
index 0000000..4fc7ade
--- /dev/null
+++ b/src/tdd/Sheet.java
@@ -0,0 +1,35 @@
+package tdd;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Sheet {
+
+ public Map sheetMap = new HashMap();
+
+ public String get(String in){
+ if (sheetMap.containsKey(in)){
+ String temp = sheetMap.get(in);
+ temp = temp.replaceAll(" +", "");
+ if (isNumeric(temp)){
+ return temp;
+ }
+ else
+ return sheetMap.get(in);
+ }
+ else
+ return "";
+ }
+
+ public boolean isNumeric(String s) {
+ return s.matches("[-+]?\\d*\\.?\\d+");
+ }
+
+ public void put(String key, String mapping){
+ sheetMap.put(key, mapping);
+ }
+
+ public String getLiteral(String in){
+ return sheetMap.get(in);
+ }
+}
diff --git a/src/tdd/testSheet.java b/src/tdd/testSheet.java
new file mode 100644
index 0000000..f724870
--- /dev/null
+++ b/src/tdd/testSheet.java
@@ -0,0 +1,79 @@
+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/DisplayScroller.java b/src/voogasalad/DisplayScroller.java
new file mode 100644
index 0000000..2110a6e
--- /dev/null
+++ b/src/voogasalad/DisplayScroller.java
@@ -0,0 +1,133 @@
+package voogasalad;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import javafx.scene.Node;
+
+/**
+ * DisplayScroller provides public methods that choose Nodes to display
+ * in a visible frame
+ *
+ * @author Hunter Lee
+ *
+ */
+public class DisplayScroller {
+
+ private int myScreenSize;
+ private int myAdjustFactor;
+ private int myConstantScrollCenter;
+
+ /**
+ * Default constructor that sets the screen size to be used
+ * in the class and myAdjustFactor which is defined to be
+ * half of the screen size
+ *
+ * @param screensize
+ */
+ public DisplayScroller(int screensize) {
+
+ myScreenSize = screensize;
+ myAdjustFactor = screensize / 2;
+ myConstantScrollCenter = 0;
+
+ }
+
+
+ /**
+ * Takes in the raw list of all Nodes in the game and mainCharLocation
+ * returns a new list of Nodes to be displayed in GameDisplay
+ *
+ * @param allNodes, rightEdgeLocation
+ * @return
+ * @deprecated Generic scroll structure for reference
+ */
+ @Deprecated
+ public List scroll(List allNodes, int mainCharLocation) {
+
+// BoundingBox myBoundingBox = new
+// List nodesToDisplay = allNodes.stream()
+// .map(n -> (Node) n)
+// .filter(n -> n.getL)
+//
+//
+//
+// allNodes.forEach(Node node -> {
+// if ())
+// });
+//
+//
+// List updatedEntries =
+// entryList.stream()
+// .peek(e -> e.setTempId(tempId))
+// .collect (Collectors.toList());
+//
+// return nodesToDisplay;
+ return null;
+
+ }
+
+ /**
+ * Takes in the raw list of all Nodes in the game and Vector
+ * returns a new list of Nodes to be displayed in GameDisplay
+ * To be called at every time step
+ *
+ * Scrolling type: centered scroll
+ *
+ * @param allNodes, rightEdgeLocation
+ * @return
+ */
+ public List centerScroll(List allNodes, double mainCharXPos) {
+
+ //double mainCharXPos = mainCharLocation.getX();
+ List nodesToDisplay;
+ if (mainCharXPos <= myAdjustFactor) {
+ nodesToDisplay = allNodes.stream()
+ .map(n -> (Node) n)
+ .filter(n -> n.getLayoutX() <= myScreenSize)
+ .collect(Collectors.toList());
+ }
+ else {
+ nodesToDisplay = allNodes.stream()
+ .map(n -> (Node) n)
+ .filter(n -> n.getLayoutX() <= mainCharXPos + myAdjustFactor)
+ .filter(n -> n.getLayoutX() >= mainCharXPos - myAdjustFactor)
+ .collect(Collectors.toList());
+ }
+ return nodesToDisplay;
+
+ }
+
+ /**
+ * Takes in the raw list of all Nodes in the game and Vector
+ * returns a new list of Nodes to be displayed in GameDisplay
+ * To be called at every time step
+ *
+ * Scrolling type: constant scrolling to the right
+ *
+ * @param allNodes, rightEdgeLocatioin
+ * @return
+ */
+ public List constantScroll(List allNodes, int speed) {
+
+ List nodesToDisplay;
+ nodesToDisplay = centerScroll(allNodes, myConstantScrollCenter);
+ myConstantScrollCenter+=speed;
+ return nodesToDisplay;
+
+ }
+
+ /**
+ * @return the myScreenSize
+ */
+ public int getScreenSize() {
+ return myScreenSize;
+ }
+
+ /**
+ * @param myScreenSize the myScreenSize to set
+ */
+ public void setScreenSize(int myScreenSize) {
+ this.myScreenSize = myScreenSize;
+ }
+
+}
diff --git a/src/voogasalad/testScroller.java b/src/voogasalad/testScroller.java
new file mode 100644
index 0000000..549bd6c
--- /dev/null
+++ b/src/voogasalad/testScroller.java
@@ -0,0 +1,37 @@
+package voogasalad;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javafx.scene.Node;
+import javafx.scene.image.ImageView;
+
+import org.junit.Test;
+
+public class testScroller {
+
+ @Test
+ public void testCenterScroll() {
+ List myList = new ArrayList<>();
+ int screensize = 600;
+
+ Node first = new ImageView();
+ first.setLayoutX(1000);
+ Node second = new ImageView();
+ second.setLayoutX(200);
+ Node third = new ImageView();
+ third.setLayoutX(500);
+
+ myList.add(first);
+ myList.add(second);
+ myList.add(third);
+
+ DisplayScroller scroll = new DisplayScroller(screensize);
+ List newList = scroll.centerScroll(myList, 100);
+
+ assertEquals(2, newList.size());
+ }
+
+}