Best way to turn a single class into multiple classes
Hello Guys
I'm still a beginner to Java and have written a programme for an assignment which is a GUI with a key pad that registers when you press a buttons on the Keypad. Type a password to unlock the programme and then type a password to unlock the programme.
It's working fine but when it's in the one single class but I need to break it into 2-3 classes but I'm having difficulty doing this successfully.
The class is made up of an arrayList to create the buttons for the Keypad and an arrayList to create the actionsListeners. I keep on running into nullPointerExceptions. Referencing things that have null values!
What are your recommendations to to do this the most efficiently
Thanks
Re: Best way to turn a single class into multiple classes
Quote:
do this the most efficiently
I'd use cut and paste.
Find sections of code that do a single function that is easily given a name, that can take parameters and return a value, cut the code and paste it into a method and replace the cut section with a call to the new method.
Re: Best way to turn a single class into multiple classes
Quote:
Originally Posted by
Norm
I'd use cut and paste.
Find sections of code that do a single function that is easily given a name, that can take parameters and return a value, cut the code and paste it into a method and replace the cut section with a call to the new method.
Thanks, that what my problem was I was trying to take too much when I should of been just using small spinets of code and turning them into methods.