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

Class version

parent 87b2ab0e
Loading
Loading
Loading
Loading
+26 −10
Original line number Diff line number Diff line
package edu.bu.ec504.hw1p1;

import com.sun.tools.javac.util.List;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.List;

public class Main {
    // constants
    static final int stateSize = 10; // the number of bytes in the myDistinctCounter object

    /**
     * Run {@link myDistinctCounter} through the test strings provided, and report its results.
     * @param testStrings The strings to run by the {@link myDistinctCounter}.
     */
    static void test(ArrayList<String> testStrings) {
        // Show the counter my test strings
        myDistinctCounter tester = new myDistinctCounter(stateSize);
@@ -26,18 +29,22 @@ public class Main {
        System.out.println("# of distinct strings: "+newFoo.numDistinct());
    }

    public static void main(String[] args) {

        // Runs a simple test, based on the example in the homework description.
    /**
     * Runs a simple test, based on the example in the homework description.
     */
    public static void runSimpleTest() {
        System.out.println("Simple test:");
        test(new ArrayList<>(List.of("Bravo", "Alfa", "Charlie", "Kilo", "Charlie", "Alfa", "Bravo")));
    }

        // A more complicated test.
        System.out.println("\n\n\nLonger test:");
        if (args.length<1)
            throw new Error("No argument supplied");
    /**
     * Runs a longer, more complicated test based on a supplied argument
     * @param arg The argument to use in the test.
     */
    public static void runLongerTest(String arg) {
        System.out.println("\n\n\n"+"Longer test:");
        final BigInteger two = new BigInteger("2");
        final BigInteger modulus = new BigInteger(1,args[0].getBytes()); // makes up a modulus based on the supplied argument
        final BigInteger modulus = new BigInteger(1,arg.getBytes()); // makes up a modulus based on the supplied argument
        BigInteger base = two;
        ArrayList<String> longList = new ArrayList<>(10000);
        for (int ii=0; ii<10000; ii++) {
@@ -46,4 +53,13 @@ public class Main {
        }
        test(longList);
    }

    public static void main(String[] args) {
        runSimpleTest();

        if (args.length<1)
            throw new Error("Please provide a command-line argument.");
        else
            runLongerTest(args[0]);
    }
}