Loading src/edu/bu/ec504/hw1p1/DistinctCounter.java +11 −9 Original line number Diff line number Diff line Loading @@ -4,15 +4,17 @@ package edu.bu.ec504.hw1p1; * Attempts to approximate the number of distinct elements seen so far. */ public abstract class DistinctCounter { // FIELDS final private Byte[] state; // METHODS // CONSTRUCTORS // ... CONSTRUCTORS /** * This constructor cannot be used. */ private DistinctCounter() { state = new Byte[0]; } private DistinctCounter() { state = null; } /** * Constructs an object backed by a given memory size. Loading @@ -31,7 +33,7 @@ public abstract class DistinctCounter { System.arraycopy(initialState, 0, state, 0, initialState.length); } // OPERATIONAL // ... OPERATIONAL /** * Log a new element that is seen. Loading @@ -45,7 +47,7 @@ public abstract class DistinctCounter { */ abstract Integer numDistinct(); // INFORMATIONAL // ... INFORMATIONAL /** * outputs the current state of the DistinctCounter * */ Loading @@ -53,7 +55,7 @@ public abstract class DistinctCounter { return state; } // FIELD final private Byte[] state; // NESTED CLASSES public static class NotYetImplemented extends RuntimeException { } } src/edu/bu/ec504/hw1p1/myDistinctCounter.java +4 −6 Original line number Diff line number Diff line package edu.bu.ec504.hw1p1; import sun.reflect.generics.reflectiveObjects.NotImplementedException; public class myDistinctCounter extends DistinctCounter { /** Loading @@ -9,7 +7,7 @@ public class myDistinctCounter extends DistinctCounter { */ public myDistinctCounter(int stateSize) { super(stateSize); throw new NotImplementedException(); // replace this with your code! throw new NotYetImplemented(); // replace this with your code! } /** Loading @@ -17,7 +15,7 @@ public class myDistinctCounter extends DistinctCounter { */ public myDistinctCounter(Byte[] initialState) { super(initialState); throw new NotImplementedException(); // replace this with your code! throw new NotYetImplemented(); // replace this with your code! } /** Loading @@ -25,7 +23,7 @@ public class myDistinctCounter extends DistinctCounter { */ @Override void saw(String newElement) { throw new NotImplementedException(); // replace this with your code! throw new NotYetImplemented(); // replace this with your code! } /** Loading @@ -33,6 +31,6 @@ public class myDistinctCounter extends DistinctCounter { */ @Override Integer numDistinct() { throw new NotImplementedException(); // replace this with your code! throw new NotYetImplemented(); // replace this with your code! } } Loading
src/edu/bu/ec504/hw1p1/DistinctCounter.java +11 −9 Original line number Diff line number Diff line Loading @@ -4,15 +4,17 @@ package edu.bu.ec504.hw1p1; * Attempts to approximate the number of distinct elements seen so far. */ public abstract class DistinctCounter { // FIELDS final private Byte[] state; // METHODS // CONSTRUCTORS // ... CONSTRUCTORS /** * This constructor cannot be used. */ private DistinctCounter() { state = new Byte[0]; } private DistinctCounter() { state = null; } /** * Constructs an object backed by a given memory size. Loading @@ -31,7 +33,7 @@ public abstract class DistinctCounter { System.arraycopy(initialState, 0, state, 0, initialState.length); } // OPERATIONAL // ... OPERATIONAL /** * Log a new element that is seen. Loading @@ -45,7 +47,7 @@ public abstract class DistinctCounter { */ abstract Integer numDistinct(); // INFORMATIONAL // ... INFORMATIONAL /** * outputs the current state of the DistinctCounter * */ Loading @@ -53,7 +55,7 @@ public abstract class DistinctCounter { return state; } // FIELD final private Byte[] state; // NESTED CLASSES public static class NotYetImplemented extends RuntimeException { } }
src/edu/bu/ec504/hw1p1/myDistinctCounter.java +4 −6 Original line number Diff line number Diff line package edu.bu.ec504.hw1p1; import sun.reflect.generics.reflectiveObjects.NotImplementedException; public class myDistinctCounter extends DistinctCounter { /** Loading @@ -9,7 +7,7 @@ public class myDistinctCounter extends DistinctCounter { */ public myDistinctCounter(int stateSize) { super(stateSize); throw new NotImplementedException(); // replace this with your code! throw new NotYetImplemented(); // replace this with your code! } /** Loading @@ -17,7 +15,7 @@ public class myDistinctCounter extends DistinctCounter { */ public myDistinctCounter(Byte[] initialState) { super(initialState); throw new NotImplementedException(); // replace this with your code! throw new NotYetImplemented(); // replace this with your code! } /** Loading @@ -25,7 +23,7 @@ public class myDistinctCounter extends DistinctCounter { */ @Override void saw(String newElement) { throw new NotImplementedException(); // replace this with your code! throw new NotYetImplemented(); // replace this with your code! } /** Loading @@ -33,6 +31,6 @@ public class myDistinctCounter extends DistinctCounter { */ @Override Integer numDistinct() { throw new NotImplementedException(); // replace this with your code! throw new NotYetImplemented(); // replace this with your code! } }