Java Reference
In-Depth Information
root : Node
children
children
label = “AC”
: Arc
: Arc
label = “ABS”
destination
destination
n1 : Node
n1 : Node
children
children children
children
label =
“yes”
label =
“no”
: Arc
: Arc
: Arc
: Arc
destination
destination
destination
destination
l1 : Node
l2 : Node
l3 : Node
l4 : Node
label = “high”
label = “medium”
label = “low”
Figure 4.7 Static structure of a sample decision tree
Using this class structure, the test decision tree, which is shown in
Figure 4.1, can be represented by a set of linked objects as shown in the
object diagram depicted in Figure 4.7.
A Node object, called root in the figure, whose label is “AC”, represents
the root node. Since the links from a node to its children have been objecti-
fied into Arc objects, the root node is connected to its children, n1 and n2,
through two Arc objects that have labels “yes” and “no” respectively. The
other nodes and arcs of the test tree are represented likewise using the class
structure shown in Figure 4.7.
4.4.3
Implementation
public class FeatureType {
private String[] allowedValues;
public FeatureType(String[] allowedValues) {
this .allowedValues # allowedValues;
}
public boolean isAllowed(String value) {
for ( int i # 0; i<allowedValues.length; !! i){
 
 
Search WWH ::




Custom Search