In which case the compiler is mistaken.Roberta Fine wrote: . . . that's what the compiler wanted. . . .
Roberta Fine wrote:Also, the same card won't get dealt twice.
So, would an ArrayList accomplish these same tasks?
Therefore, I would like to make the deck myself using two arrays and then load them into a vector.
Why, because a vector resizes dynamically which is useful when dealing out cards.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
You believe correctly; here it is.Winston Gutkowski wrote: . . . (I believe the JLS also has an example).
HIH
Winston
What I showed was a List of Lists of Strings, which is what you asked about initially.
I hope you mean a 'vector' in the generic sense, and not java.util.Vector, which is basically a legacy class. ArrayList is almost always preferable to a Vector.
I'm also not quite sure why you would need two arrays. A standard playing deck consists of 52/54 cards, each of which is unique (apart from the Jokers, but you could make those "unique" too if you want).
That link looks very similar to what I posted. There are two major differences:Roberta Fine wrote: . . . this link:
http://stackoverflow.com/questions/1474954/working-with-a-list-of-lists-in-java
. . .
Is this what you mean? I definitely want to learn it correctly, thanks...![]()
Nononononono. Don't use ints. The whole idea of enums is to get away from using plain numbers. Read the Java Tutorials, where you find this:Roberta Fine wrote: . . . a playing card, . . . Please advise on using integers for the rank and suit values. I'm not exactly sure how an enum would work in this case.
Thanks in advance.
In the version of the Java Tutorials I used when learning, that sentence ended something like, “…which are merely glorified integers,” but I think there were complaints making them remove that bitJava programming language enum types are much more powerful than their counterparts in other languages.
I do some of my very best work in water. Like this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|