diff --git a/build/kdiv/Main.class b/build/kdiv/Main.class deleted file mode 100644 index 5f3d8c0f4229cbe79a93413191de9194f972a8a2..0000000000000000000000000000000000000000 Binary files a/build/kdiv/Main.class and /dev/null differ diff --git a/dist/kdiv.jar b/dist/kdiv.jar deleted file mode 100644 index 9ba16f3d90fda6726c70e0b0e5cc974940147189..0000000000000000000000000000000000000000 Binary files a/dist/kdiv.jar and /dev/null differ diff --git a/src/kdiv/Distribution.java b/src/kdiv/Distribution.java new file mode 100644 index 0000000000000000000000000000000000000000..a603575dacc190fb56d2afd74c80718da9b386e6 --- /dev/null +++ b/src/kdiv/Distribution.java @@ -0,0 +1,58 @@ +package kdiv; + +import java.util.HashMap; +import java.util.Map; + +/** + * The Distribution class manages a collections of Objects and their associated values. + */ +public class Distribution { + private Map<Object, Integer> objectMap; + + /** + * Initialization + */ + public Distribution() { + this.objectMap = new HashMap<>(); + } + + /** + * Adds an object with an associated integer value. + * @param obj The object to store. + * @param value The integer value associated with the object. + */ + public void addObject(Object obj, int value) { + objectMap.put(obj, value); + } + + /** + * Retrieves the value of a given object. + * @param obj The object to look up. + * @return The associated integer value, or null if not found. + */ + public Integer getValue(Object obj) { + return objectMap.getOrDefault(obj, null); + } + + /** + * Checks if the object exists in the distribution. + * @param obj The object to check. + * @return True if the object exists, false otherwise. + */ + public boolean contains(Object obj) { + return objectMap.containsKey(obj); + } + + /** + * Gets the entire distribution as a HashMap. + * @return The HashMap storing object-value pairs. + */ + public Map<Object, Integer> getObjectMap() { + return objectMap; + } + + @Override + public String toString() { + return objectMap.toString(); + } +}