From ba3a7339282fdbd844f711db04794e427d9500c1 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 26 Jul 2017 19:16:10 -0700 Subject: [PATCH] Add comments to NumberReducer and FunctionNode. --- src/org/nwapw/abacus/tree/FunctionNode.java | 24 ++++++++++++++++++++ src/org/nwapw/abacus/tree/NumberReducer.java | 11 +++++++++ 2 files changed, 35 insertions(+) diff --git a/src/org/nwapw/abacus/tree/FunctionNode.java b/src/org/nwapw/abacus/tree/FunctionNode.java index bd82d38..f8dc8c8 100644 --- a/src/org/nwapw/abacus/tree/FunctionNode.java +++ b/src/org/nwapw/abacus/tree/FunctionNode.java @@ -2,22 +2,46 @@ package org.nwapw.abacus.tree; import java.util.ArrayList; +/** + * A node that represents a function call. + */ public class FunctionNode extends TreeNode { + /** + * The name of the function being called + */ private String function; + /** + * The list of arguments to the function. + */ private ArrayList children; + /** + * Creates a function node with no function. + */ private FunctionNode() { } + /** + * Creates a new function node with the given function name. + * @param function the function name. + */ public FunctionNode(String function){ this.function = function; children = new ArrayList<>(); } + /** + * Gets the function name for this node. + * @return the function name. + */ public String getFunction() { return function; } + /** + * Adds a child to this node. + * @param node the child to add. + */ public void addChild(TreeNode node){ children.add(node); } diff --git a/src/org/nwapw/abacus/tree/NumberReducer.java b/src/org/nwapw/abacus/tree/NumberReducer.java index 2f71347..ab80374 100644 --- a/src/org/nwapw/abacus/tree/NumberReducer.java +++ b/src/org/nwapw/abacus/tree/NumberReducer.java @@ -4,10 +4,21 @@ import org.nwapw.abacus.function.Function; import org.nwapw.abacus.number.NumberInterface; import org.nwapw.abacus.plugin.PluginManager; +/** + * A reducer implementation that turns a tree into a single number. + * This is not always guaranteed to work. + */ public class NumberReducer implements Reducer { + /** + * The plugin manager from which to draw the functions. + */ private PluginManager manager; + /** + * Creates a new number reducer with the given plugin manager. + * @param manager the plugin manager. + */ public NumberReducer(PluginManager manager){ this.manager = manager; }