1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-11-18 08:29:33 -08:00
Abacus/src/org/nwapw/abacus/tree/NumberNode.java

48 lines
1.0 KiB
Java
Raw Normal View History

package org.nwapw.abacus.tree;
import org.nwapw.abacus.number.NaiveNumber;
import org.nwapw.abacus.number.NumberInterface;
2017-07-26 10:10:37 -07:00
/**
* A node implementation that represents a single number.
*/
public class NumberNode extends TreeNode {
2017-07-26 10:10:37 -07:00
/**
* The number that is represented by this number node.
*/
private NumberInterface number;
2017-07-26 10:10:37 -07:00
/**
* Creates a number node with no number.
*/
public NumberNode(){
number = null;
}
2017-07-26 10:10:37 -07:00
/**
* Creates a new number node with the given double value.
* @param value the value to use.
*/
public NumberNode(double value){
number = new NaiveNumber(value);
}
2017-07-26 10:10:37 -07:00
/**
* Creates a new number node with the given string value, converted
* to a double.
* @param value the value.
*/
public NumberNode(String value){
this(Double.parseDouble(value));
}
2017-07-26 10:10:37 -07:00
/**
* Gets the number value of this node.
* @return the number value of this node.
*/
public NumberInterface getNumber() {
return number;
}
}