CSC407/ECE450 Assignment 1b Sample Solution

plan.dom
Class DefaultFeatureListImplementation

java.lang.Object
  |
  +--plan.dom.DefaultFeatureListImplementation
All Implemented Interfaces:
FeatureList
Direct Known Subclasses:
Release, Software

abstract class DefaultFeatureListImplementation
extends java.lang.Object
implements FeatureList

Default implementation of FeatureList minus the getLabel() method


Field Summary
private  java.util.Vector features
           
 
Constructor Summary
(package private) DefaultFeatureListImplementation()
           
 
Method Summary
 void addFeature(Feature f)
          Add the indicated feature to the list.
 java.util.Iterator featureIterator()
          Get an Iterator over the features.
 int numFeatures(Priority p)
          Returns the number of features broken out by priority.
protected  void sortFeatures(java.util.Comparator compare)
          Sort features according to the order given by the Feature Comparator.
protected  void subtract(DefaultFeatureListImplementation other)
          Remove all features in the other list from this one.]
 double totalSizingOfFeatures(Priority p)
          Returns the total sizing of features broken out by priority.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface plan.dom.FeatureList
getLabel
 

Field Detail

features

private java.util.Vector features
Constructor Detail

DefaultFeatureListImplementation

DefaultFeatureListImplementation()
Method Detail

featureIterator

public java.util.Iterator featureIterator()
Get an Iterator over the features.
Specified by:
featureIterator in interface FeatureList
Returns:
the requested Iterator

addFeature

public void addFeature(Feature f)
Add the indicated feature to the list.
Parameters:
f - the feature to add

sortFeatures

protected void sortFeatures(java.util.Comparator compare)
Sort features according to the order given by the Feature Comparator.
Parameters:
comapre - a Comparator for features.

subtract

protected void subtract(DefaultFeatureListImplementation other)
Remove all features in the other list from this one.]
Parameters:
other - the feature list to substract from this one

numFeatures

public int numFeatures(Priority p)
Returns the number of features broken out by priority.
Specified by:
numFeatures in interface FeatureList
Parameters:
p - if null, all features, else only features of the given priority
Returns:
the count of the specified features

totalSizingOfFeatures

public double totalSizingOfFeatures(Priority p)
Returns the total sizing of features broken out by priority.
Specified by:
totalSizingOfFeatures in interface FeatureList
Parameters:
p - if null, all features, else only features of the given priority
Returns:
the total of the sizings of the specified features

CSC407/ECE450 Assignment 1b Sample Solution