• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Factory pattern problem

 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello i am trying example with factory pattern but i get an error. This is my code if anyone can help


the error is



and the code is








Why do i get such a message ?I have try the args[] array but it will not change.what can i do?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Horche. Welcome to the Ranch!

Anyway, I assume Factory.java line 29 corresponds to line 12 in that listing? In that case, the problem is that the argument array doesn't have two entries. Maybe you should print out the array to check what it does actually contain. How are you executing the program?
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3165
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Horche Gratsias wrote:
Why do i get such a message ?I have try the args[] array but it will not change.what can i do?

String[] args is equivalent to String args[].
As Matthew pointed out the possible erroneous line, I think you are using an IDE to run the program and you need to setup the IDE to accept command line arguments.
 
rajareddy dodda
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes as mentioned above how the parameters passed to the program, look into that will make more clear .
 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply
 
Junilu Lacar
Bartender
Pie
Posts: 8777
81
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to take a look at http://www.oodesign.com/factory-pattern.html to pick up some tips on a better implementation. As you'll see, your current implementation is what the article calls a "noob implementation" and violates what is called the "Open-Closed Principle" of object-oriented design.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic