War Card Game | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

War Card Game

I'm thinking about making the card game war in java. I was thinking about how to represent a deck of cards. Should I have one array with all the cards in it, or should I make two arrays, one with the suit and the other with the number? Any suggestions on this or on how to go about coding it are welcome. ;)

16th Feb 2017, 1:45 AM
J.G.
J.G. - avatar
9 Answers
16th Feb 2017, 2:43 AM
Tristan McCullen
Tristan McCullen - avatar
+ 6
@J.G. A few links to consider. Might help you get a clue on the base classes, arrays and structure in general: http://nifty.stanford.edu/2004/EstellCardGame/code.html# A full tutorial even for the average: http://www.dreamincode.net/forums/topic/116864-how-to-make-a-poker-game-in-java/
16th Feb 2017, 2:59 AM
Tristan McCullen
Tristan McCullen - avatar
+ 5
right! my bad! java offers fantastic oop so that shouldn't be a prob. :)
16th Feb 2017, 2:38 AM
Tristan McCullen
Tristan McCullen - avatar
+ 5
I tried it and got python...
16th Feb 2017, 2:46 AM
J.G.
J.G. - avatar
+ 4
Ahh... I didn't think of that. It will be interesting to try. Thank you for the suggestion. ;)
16th Feb 2017, 2:29 AM
J.G.
J.G. - avatar
+ 4
@Tristan I am not an HTML programmer, which is one of the reasons why everything you say is confusing to me. But I understand that, so okay. It would be better to do it in that instead of in java, but I just wanted to make something a little more difficult and have it record (output) the results.
16th Feb 2017, 2:34 AM
J.G.
J.G. - avatar
+ 4
Thanks for all of the help. I'm getting pretty busy right now, so it may be a while before I get back to you.
17th Feb 2017, 2:36 AM
J.G.
J.G. - avatar
+ 3
I'd create class "Card" with fields like, "color", "number" and "suit". Then create "Player" class which includes array of Cards objects. Hope it helped ^^
16th Feb 2017, 2:00 AM
Jakub Stasiak
Jakub Stasiak - avatar
+ 3
That's why I'm learning it (or one of the reasons)
16th Feb 2017, 2:42 AM
J.G.
J.G. - avatar