1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-11-13 14:19:53 -08:00

Add comments to NumberReducer and FunctionNode.

This commit is contained in:
Danila Fedorin 2017-07-26 19:16:10 -07:00
parent 49f6f2d21e
commit ba3a733928
2 changed files with 35 additions and 0 deletions

View File

@ -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<TreeNode> 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);
}

View File

@ -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<NumberInterface> {
/**
* 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;
}