0

I am new to java, I have a class HashSet<Proposition>Propositions,

class Proposition have 4 class Variable:

public class Proposition extends HashSet<Proposition> implements RSTNode{
private String productName;
    private Property     property;
    private Serializable value;
    private Type         type;
    private Rating       rating;
}

and class Propositions is as follow:

public class Propositions extends ArrayList<Proposition>{ 
........
}

I have class RST Rule as follow:

public class RSTRule{
    protected String ruleName;
    protected String discourseRelation;
    protected RSTNode nucleus;
    protected RSTNode satellite;
    protected Condition condition;
    int heuristic;
    }

now i have another class namely RSTRules, which contains some methods such as generate_1(),generate_2(),... in this methods i want to write some condition in field condition, which if this condition is true then i should run the related generate methode but if condition is not true i should go to another generate methode and check it's condition an so on, I thought for this propblem i should have a seperate class namely "Condition" to check condition, but i do not know how should write the methods in Condition Class or Constructors also, that means my Condition Class is empty now!!!!!!

public class RSTRules extends ArrayList<RSTRule>  {
    RSTRule rstRule=new RSTRule();            
    Proposition prop1= new Proposition();
    Proposition prop2= new Proposition();   

    public RSTRule generate_1(){    
    my condition for generate_1() is like this:if(prop1.getName().equals.prop2.getName();
       rstRule.condition=.....
       rstRule.satellite=propSat;
       rstRule.nucleus=propNuc;
       rstRule.ruleName="BothSatisfy_ProductsSimilarities"
       rstRule.discourseRelation="Similarity"
       rstRule.heuristic=10;
       return rstRule;
    }



    public RSTRule generate_2(){
    my condition for generate_2() is like this: if(prop1.getValue().equals.prop2.getValue()

    rstRule.condition=.....
    rstRule.satellite=propSat;
    rstRule.nucleus=propNuc;
    rstRule.ruleName="BothFunction"
    rstRule.discourseRelation="Similarity"
    rstRule.heuristic=10;
    return rstRule;
    }
}
Aritz
  • 30,971
  • 16
  • 136
  • 217
man
  • 85
  • 3
  • 7
  • I'm not sure I understand this... Ok i'll try: in your RSTRules class, create a method generate_any() with a switch case on prop1.getValue(), in each case, call the right generate method. – Fabinout Sep 20 '13 at 10:00
  • but i can not do this, because some times i should check value , some times i should check name , some another condition also – man Sep 20 '13 at 10:04
  • So `Condition` should have a method `boolean eval(Context ctx)` one needs to override, and the Context providing access to everything. – Joop Eggen Sep 20 '13 at 10:07

0 Answers0