Win a copy of Modern frontends with htmx this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Dealing with cards in a deck

Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following code and what I want to figure out is when I deal out the card and face them down I want to take the top card and show its value and suit. I already know how to deal the cards to the players and flip the cards. Just need help/advice on showing that card.

Here is deck class

Here is card class

Here is where my problem is
Posts: 17644
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The player's cards are in the hand array right? Which element of that array represents the top card? Then doesn't a card have a toString() method?

Why are you doing this in the Player constructor?

This code is saying "The player will initially have a hand with 26 blank Cards".

Did you really mean to do that? If this were a real card game and you dealt me a hand with 26 blank cards, I'd be all

Lastly, while it's admirable that you are trying to write JavaDocs, you should read this document: so you know how to write them properly. When it comes to JavaDocs, you should conform to the conventions given in that document and yours don't.
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic