I'm writing a small Java program that randomly deals out playing cards, then displays them on screen in a window.
Since I'm using NetBeans, the GUI was started for me, and I've been writing my methods for randomly choosing cards, setting up an array to store whether or not a card has already been dealt, etc., all in the same class NetBeans set up for me when it built the JFrame.
I'd like to move all my non-GUI code into its own Class, and then just pass data back to the GUI class as needed to display the cards, but I'm not sure of the best way to share data between the two classes.
I know about set/get methods and I know I could make public class-level variables, but everything I've been reading tells me to avoid both as much as possible.
Right now I have a method that generates an int between 1 and 52 for each card dealt. 1 = Ace of spades, 2= 2 of spades, etc. Once the GUI has that number, it can display the appropriate card in the appropriate place on the screen (or at least it will be able to once I've coded the GUI side of things). If I'm looking to pass that integer value to the GUI class, then display a specific card on the screen based on that value, how should I do it?
Seems to me a public variable would make this easy, as would a simple get method...but in the interest of avoiding those options is there another way?
I can provide code snippets if that helps.