Loading src/edu/bu/ec504/hw1p1/DistinctCounter.java +2 −3 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ public abstract class DistinctCounter { */ private DistinctCounter() { state = new Byte[0]; }; } /** * Constructs an object backed by a given memory size. Loading @@ -28,8 +28,7 @@ public abstract class DistinctCounter { */ public DistinctCounter(Byte[] initialState) { state = new Byte[initialState.length]; for (int ii=0; ii<initialState.length; ii++) state[ii]=initialState[ii]; System.arraycopy(initialState, 0, state, 0, initialState.length); } // OPERATIONAL Loading src/edu/bu/ec504/hw1p1/Main.java +9 −4 Original line number Diff line number Diff line package edu.bu.ec504.hw1p1; import java.util.Arrays; public class Main { public static void main(String[] args) { /** * Runs a simple test, based on the example in the homework description. */ static void simpleTest() { String[] testStrings = {"Bravo", "Alfa", "Charlie", "Kilo", "Charlie", "Alfa", "Bravo"}; myDistinctCounter foo = new myDistinctCounter(10); for (String test: testStrings) { foo.see(test); foo.saw(test); } Byte[] savedState = foo.currentState(); Loading @@ -17,4 +18,8 @@ public class Main { myDistinctCounter newFoo = new myDistinctCounter(savedState); System.out.println(newFoo.numDistinct()); } public static void main(String[] args) { simpleTest(); } } src/edu/bu/ec504/hw1p1/myDistinctCounter.java 0 → 100644 +38 −0 Original line number Diff line number Diff line package edu.bu.ec504.hw1p1; import sun.reflect.generics.reflectiveObjects.NotImplementedException; public class myDistinctCounter extends DistinctCounter { /** * @InheritDoc */ public myDistinctCounter(int stateSize) { super(stateSize); throw new NotImplementedException(); // replace this with your code! } /** * @InheritDoc */ public myDistinctCounter(Byte[] initialState) { super(initialState); throw new NotImplementedException(); // replace this with your code! } /** * @InheritDoc */ @Override void saw(String newElement) { throw new NotImplementedException(); // replace this with your code! } /** * @InheritDoc */ @Override Integer numDistinct() { throw new NotImplementedException(); // replace this with your code! } } Loading
src/edu/bu/ec504/hw1p1/DistinctCounter.java +2 −3 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ public abstract class DistinctCounter { */ private DistinctCounter() { state = new Byte[0]; }; } /** * Constructs an object backed by a given memory size. Loading @@ -28,8 +28,7 @@ public abstract class DistinctCounter { */ public DistinctCounter(Byte[] initialState) { state = new Byte[initialState.length]; for (int ii=0; ii<initialState.length; ii++) state[ii]=initialState[ii]; System.arraycopy(initialState, 0, state, 0, initialState.length); } // OPERATIONAL Loading
src/edu/bu/ec504/hw1p1/Main.java +9 −4 Original line number Diff line number Diff line package edu.bu.ec504.hw1p1; import java.util.Arrays; public class Main { public static void main(String[] args) { /** * Runs a simple test, based on the example in the homework description. */ static void simpleTest() { String[] testStrings = {"Bravo", "Alfa", "Charlie", "Kilo", "Charlie", "Alfa", "Bravo"}; myDistinctCounter foo = new myDistinctCounter(10); for (String test: testStrings) { foo.see(test); foo.saw(test); } Byte[] savedState = foo.currentState(); Loading @@ -17,4 +18,8 @@ public class Main { myDistinctCounter newFoo = new myDistinctCounter(savedState); System.out.println(newFoo.numDistinct()); } public static void main(String[] args) { simpleTest(); } }
src/edu/bu/ec504/hw1p1/myDistinctCounter.java 0 → 100644 +38 −0 Original line number Diff line number Diff line package edu.bu.ec504.hw1p1; import sun.reflect.generics.reflectiveObjects.NotImplementedException; public class myDistinctCounter extends DistinctCounter { /** * @InheritDoc */ public myDistinctCounter(int stateSize) { super(stateSize); throw new NotImplementedException(); // replace this with your code! } /** * @InheritDoc */ public myDistinctCounter(Byte[] initialState) { super(initialState); throw new NotImplementedException(); // replace this with your code! } /** * @InheritDoc */ @Override void saw(String newElement) { throw new NotImplementedException(); // replace this with your code! } /** * @InheritDoc */ @Override Integer numDistinct() { throw new NotImplementedException(); // replace this with your code! } }