Guest User

problem

a guest
Apr 30th, 2013
206
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class AFactory {
  2.     public A create(String name){/*Create the correct A*/}
  3. }
  4.  
  5. public abstract class A {
  6.     public abstract void doStuff(String argument);
  7. }
  8.  
  9. public class A1 extends A{
  10.     public void doStuff(String argument){/*some usage of argument*/}
  11. }
  12. .
  13. .
  14. .
  15. public class AN extends A{
  16.     public void doStuff(String argument){/*some usage of argument*/}
  17. }
  18.  
  19. public class B extends A{
  20.     public void doStuff(String argument){
  21.         /*I need otherArgument too!
  22.          * And it's not in the UserInput class which I
  23.          * cannot change/inherit/modify in any way :|
  24.         */
  25.     }
  26. }
  27.  
  28. public class Interpreter{
  29.     Interpreter(){}
  30.     public Stuff interpret(UserInput userInput)
  31.     /* read the user input and do MANY things with the input
  32.      * one of them  might be calling AFactory.create
  33.      * and in the end Runner will get its A instances
  34.     */
  35. }
  36.  
  37. public class Runner{
  38.     public static void run(){
  39.         /* Runner needs otherArgument which B needs but
  40.          * for something else
  41.          */
  42.         for(String argument : listOfArguments){
  43.             for(A actualA : listOfA)
  44.                 actualA.doStuff(argument);
  45.         }
  46.     }
  47. }
  48.  
  49. public class EntryPoint{
  50.     /* Has both UserInput and otherArgument
  51.      * it calls the interpreter.
  52.     */
  53. }
RAW Paste Data