File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Factory pattern problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Factory pattern problem " Watch "Factory pattern problem " New topic
Author

Factory pattern problem

Georgios Chatziefstratiou
Ranch Hand

Joined: May 26, 2012
Posts: 83
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

Joined: Apr 06, 2010
Posts: 4460
    
    8

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

Joined: Sep 08, 2007
Posts: 3071
    
  33

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.


Mohamed Sanaulla | My Blog
rajareddy dodda
Greenhorn

Joined: Jun 25, 2008
Posts: 15
Yes as mentioned above how the parameters passed to the program, look into that will make more clear .
Georgios Chatziefstratiou
Ranch Hand

Joined: May 26, 2012
Posts: 83
Thanks for your reply
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4991
    
    8

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.


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Factory pattern problem