Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AFactory {
- public A create(String name, String otherArgument){/*Create the correct A*/}
- /* ----->
- * But now I receive otherArgument as well and I do nothing with it
- * unless I need to create an instance of B
- */
- }
- public abstract class A {
- public abstract void doStuff(String argument);
- }
- public class A1 extends A{
- public void doStuff(String argument){/*some usage of argument*/}
- }
- .
- .
- .
- public class AN extends A{
- public void doStuff(String argument){/*some usage of argument*/}
- }
- public class B extends A{
- public void doStuff(String 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, String otherArgument)
- /* 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
- */
- /* ----->
- * But now I hold otherArgument as well and I do nothing with it
- * unless I need to create an A
- */
- }
- 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)
- actualA.doStuff(argument);
- }
- }
- }
- public class EntryPoint{
- /* Has both UserInput and otherArgument
- * it calls the interpreter.
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement