I have a project that im working on for a couple of days. I wanna make a card game (about texas holdem) that shows you 3 cards (the flop) and you need to tell if that flop is good or not for a bet. So, i made a class Fereastra.java (Window.Java in my native language), a class Face.java, Suit.java that generates a random face and suit from an enum and returns it as a string. I also made a Card.java class. Now i have to make a Flop.java class that shows the images (3) representation of the each card randomly chosen. I made an Flop.properties file in wich i put FAd = Ad.png ( face ace of diamonds) and so on for each card. My Flop.properties is in the practice.resources.carti package. carti means cards. I have to somehow tell Flop.java or Card.java to look in the Flop.properties for the image name that is chosen. To explain better i post the code below. Btw, im working in NetBeans.
h, s, d, c means heart, spade, diamond, club
I guess is also something wrong in the Card constructor.
If, in the main class Fereastra.java or in the Flop.java class, i do this:
I get errors.
To summarize i want, when i call Flop() to be displayed 3 cards randomly chosen on my JLabel.
Any help would be very appreciated. Also some feedback about my english is appreciated.
PS: If its something that i posted other than in english (and i didnt explained it) or you dont understand something please tell me.
Thanks for reading this.
"I get errors" doesn't really help us much. Errors when you compile? run? save? Telling the details is critical. What are you doing that generates the errors, and what is the exact text of those errors?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Also, I really suggest you rename your enum constants. If you have to explain to us what h, s, d and c mean that should already signal that they are improperly named. So use proper names:
I'd rather read Suit.Hearts and Face.Four than Suit.V_h and Face.V_4.
Hi Rob, thanks for the reply. Yes i imported ImageIcon, and thanks again for feedback i will replace them. About the problem, i think its because i put that card inside ImageIcon(). So i without card inside it works fine. Im thinking of something like:
Well i know it must be a String but the Card class has to make it a String. The way i see it, in the Card class constructor it gets a random face (for example: A) and a random suit (for examaple d) and it adds them together:
I tried also with:
But doesnt seem to work either. So after doing that Card = Ad (in this example) and that need to be replaced with "Ad.png" from my Flop.properties.
Joined: Jan 31, 2011
I modified the Card.java class:
And i made the Flop.java like this:
And in the the Fereastra.java class (that makes the window) at the actionListener of a button i putted:
And i get some strange errors:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at practice.Flop.<init>(Flop.java:16)