Commit e783275e authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

Added scaffolding.

parent 2774d749
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ public abstract class DistinctCounter {
     */
    private DistinctCounter() {
        state = new Byte[0];
    };
    }

    /**
     * Constructs an object backed by a given memory size.
@@ -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
+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();
@@ -17,4 +18,8 @@ public class Main {
        myDistinctCounter newFoo = new myDistinctCounter(savedState);
        System.out.println(newFoo.numDistinct());
    }

    public static void main(String[] args) {
        simpleTest();
    }
}
+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!
  }
}