This post has been de-listed (Author was flagged for spam)
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Sorry if there's something obvious I missed here. For example, let's say I'm making a card game and want to make store a bunch of constants of type Card
in a class Cards
. After all, there are only a limited number of kinds of playing cards so it makes sense to store them all as reference values. This might be useful if I had a method Deck.hasCard(Card c)
, for example. If I want to see if a Deck has a five of spades, for example, I shouldn't have to create a new Card()
just to do that. However, I don't see a way to do that without either manually specifying every kind of card possible, (the two ways I know how to do this are to either use an enum
, or maybe make a regular class then include them as part of a data structure like ArrayList<>
) or including a constructor to iterate over the suits and values which doesn't make sense for what is basically an enum
. Please let me know if I'm wrong about or missing something.
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/javahelp/co...