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

Class version

parent acaab57c
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -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.
@@ -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.
@@ -45,7 +47,7 @@ public abstract class DistinctCounter {
     */
    abstract Integer numDistinct();

    // INFORMATIONAL
    // ... INFORMATIONAL
    /**
     * outputs the current state of the DistinctCounter
     * */
@@ -53,7 +55,7 @@ public abstract class DistinctCounter {
        return state;
    }


    // FIELD
    final private Byte[] state;
    // NESTED CLASSES
    public static class NotYetImplemented extends RuntimeException {
    }
}
+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 {

  /**
@@ -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!
  }

  /**
@@ -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!
  }

  /**
@@ -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!
  }

  /**
@@ -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!
  }
}