I have the question regarding the code snippet below.
interface Component{
boolean isRelevant();
}
public abstract class AbstractComponent implements Component {
String componentType;
List<String> data;
public AbstractComponent(String componentType, List<String> data) {
//assign values.
}
}
class ComponentA implements Component {
//Constructor with super method to pass type and data to parent class.
public boolean isRelevant() {
//Use data to check relevance.
}
} and so on components.
//Main program to Test
List<Component> components; //Initialize all Components with type and data.Ex: new Component("CompA", Data);
Iterate through the Component and run isRelevance over components.
for each component {
boolean flag = comp.isRelevant()
//HOW DO I Check Component Type here that need to be used in next section as i explained?
}
Secondly based on the combination of Components with true/false, we will arrive with name. Ex: CompA is relevant, B is relevant and C is not. ===> "Good" CompA is not relevant, B is relevant and C is not. ===> "Better" I was thinking of creating a Map with 1/0 bit flags combination and assigning the name. Say "110" => Good. Can i have some suggestions on giving a better design/implementation approach for this?
Aucun commentaire:
Enregistrer un commentaire