Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Create a new class called AParams */
- public class AParams{
- AParams();
- get/setArgument(String argument);
- get/setOtherArgument(String argument);
- }
- public class AFactory {
- public A create(String name){/*Create the correct A*/}
- }
- public abstract class A {
- public abstract void doStuff(AParams argument);
- }
- public class A1 extends A{
- public void doStuff(AParams argument){/*some usage of argument*/}
- }
- .
- .
- .
- public class AN extends A{
- public void doStuff(AParams argument){/*some usage of argument*/}
- }
- public class B extends A{
- public void doStuff(AParams argument){
- /*I need otherArgument too!
- * And it's not in the UserInput class which I
- * cannot change/inherit/modify in any way :|
- */
- }
- }
- public class Interpreter{
- Interpreter(){}
- public Stuff interpret(UserInput userInput)
- /* read the user input and do MANY things with the input
- * one of them might be calling AFactory.create
- * and in the end Runner will get its A instances
- */
- }
- public class Runner{
- public static void run(){
- /* Runner needs otherArgument which B needs but
- * for something else
- */
- for(String argument : listOfArguments){
- for(A actualA : listOfA)
- AParams params = new AParams();
- params.setArgument(argument);
- params.setOtherArgument(otherArgument);
- actualA.doStuff(params);
- }
- }
- }
- public class EntryPoint{
- /* Has both UserInput and otherArgument
- * it calls the interpreter.
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement