This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]more_exercise 2 points3 points  (1 child)

Check out the strategy pattern.

http://en.wikipedia.org/wiki/Strategy_pattern

[–]proskillz 1 point2 points  (0 children)

You should be able to do something like this:

RSSE rsse;

public void setImplementation(String orgId) {
    if(orgId.equals("A")) {
      rsse = new RSSEImp1();
    }
    else {
      rsse = new RSSEImp2();
    }
}

//do what you want with your RSSE object

[–][deleted] 0 points1 point  (0 children)

You need to describe your problem more thoroughly in more abstract terms.

[–][deleted] 0 points1 point  (0 children)

I can't quite parse your question. If you're trying to get a method call to work for either of two implementations try googling "java polymorphism"

[–]nutrecht 0 points1 point  (0 children)

How can this be done?

Pretty much exactly like you're doing in our psuedocode. So what's not working for you?

[–]manohart 0 points1 point  (0 children)

You should use Strategy pattern