inheritance? interface?
Hi, I have used inheritance incorrectly... could you point out how do I fix it please? My code looks like this:
publicabstractclass FeatureSpace{
publicvoid methodA(){
}
}
publicclass FeatureSpaceImplA{
publicvoid methodB(){
}
}
publicclass FeatureSpaceImplB{
publicvoid methodC(){
}
}
publicabstractclass FeatureSpaceBuilder(){
//This method takes an article content(String), analyse the article and create its
//feature space; the feature are stored in the method argument "space".
//Instead of returning a new FeatureSpace by the method itself,
//I'd like to pass a FeatureSpace object to the method, and modify it by the method;
//the reason is this method will be used iteratively, but eventually build only *one* FeatureSpace.
// Consider given a corpus of 100 articles, this method will be called
//100 times, building Features for each article, but store features in a
// single FeatureSpace as for the whole corpus. So instead of creating
// and returning then merging a new FeatureSpace each time, I just
// pass the single FeatureSpace object to the method every iteration, and
//modifies it.
abstractvoid buildFeatureSpace(String article, FeatureSpace space);
}
publicclass FeatureSpaceBuilderImplA(){
publicvoid buildFeatureSpace(String article, FeatureSpaceImplA space){
......
}
}
publicclass FeatureSpaceBuilderImplB(){
publicvoid buildFeatureSpace(String article, FeatureSpaceImplB space){
......
}
}
As you see, I need to use inheritance on the method arguments, but the compiler complains
"public abstract void buildFeatureSpace(String article,FeatureSpace space)"
needs to be implemented in both sub-classes.
I have defined separate methods in each sub class as:
""public abstract void buildFeatureSpace(String article,FeatureSpaceImplB space)"
"public abstract void buildFeatureSpace(String article,FeatureSpaceImplA space)"
Where "FeatureSpaceImplA" and "FeatureSpaceImplB" extends "FeatureSpace". But this doesnt work. I need to use specifc "FeatureSpace" in above two methods because their behaviors are different.
I feel that I may have done this in totally wrong way.... can you give me some advice pleas, many thanks!

