Hey all! Thanks for the replies. I marked this as resolved because I thought I'd give it another go on my own. I scrapped all the code I wrote and started from scratch, this time trying to closely follow factory design pattern template in my textbook.
These design patterns are basically "best practices" and by learning these patterns, inexperienced programmers such as myself can learn software design more easily. I know the Factory design pattern is an ideal way to create objects in
java. It uses a common interface to create its new objects. The singleton pattern is an ideal way to create a single object and to ensure only one instance of that single object is created.
@ Junilu After re-reading my question, it looked like I was asking you all "Here's my code, now re-write it for me this way." That's what i meant by asking too much, so I marked it resolved and tried it on my own. I think the way it was explained to me (using shapes instead of text fields and demonstrated in Greenfoot (a java learning environment) and not in an
IDE) I was a bit intimidated about getting started so I just wrote the program the way I knew how.
@ Winston & Junilu I admit, the more I read, it seems like Singleton submit button is not the way to go, but this is what I was asked for. However, my mention that "When the submit button is clicked, a pop-up should show all the information that was typed into all of the form fields." was not part of the assignment, just something I thought would be helpful for me for
testing purposes.
Still working on the singleton submit button but here's what I have so far:
Form.java file
Name.java file (I have a similar files just like this for Address.java, City.java, State.java, Zip.java and Phone.java)
FormFactory.java file
FormFactoryDemo.java file
As I said I am still working on it, but because you guys were nice enough to respond I thought I'd post what I have presently. It compiles at the moment but I get a null pointer exception in the main method of the FormFactoryDemo file. Need to add that singleton design pattern submit button ASAP so I can work through this.
Can you tell me if I am on the right track at least?? Thanks to all for your input and advice it was extremely helpful!