Campbell Ritchie wrote:Apart from the fact that you have the faces out of order, with the Ace below the Deuce
All right. But does a card have any value at all, apart from a game rule?
Stephan van Hulst wrote:. . . There is no standard order that says that the Ace comes before the Deuce, or after the King.
Didn't notice that.
. . . the OP wrote "Joker" instead of "Jack".
Yes, and no. You are declaring the same thing twice. Haven't they told you about declaring the same thing twice? In the second instance it is a local variable which goes out of scope before you ever do anything with it. I would make the changes shown below:-
Ana Yo wrote:Is the logic error that I have two of the exact same lines and I should delete it?
I would also check the formatting; the excess empty lines make the code harder to read. I would also declare deck as List<Card>.
public class StandardDeck
= new ArrayList<Card>(52);
*Post-condition: An ArrayList of objects of type Card will be created
ArrayList<Card>deck = new ArrayList<Card>(52);
Thank you; I hadn't noticed that. In which case I would have to change the constructor to read:-. . . and buildDeck() has to change its return type.
Dave Tolls wrote:. . . part of the comment (which I assume is the requirements) for the buildDeck method . . .
Ana Yo wrote:Hi there, I just started learning about ArrayLists and I am trying to implement a deck of cards. The instructions are:
*Post-condition: A new ArrayList of cards will be created with 52 cards.
*There will be 4 suits with 13 cards each.
This is what I have so far:
I don't know if I should add more code or not.
Campbell Ritchie wrote:I am not sure that will work, because OP is required to produce a List<Card>. I don't know why she said anything about a List<Integer>.
Don't worry about it.
Michael D Sims wrote:. . . . ... my bad.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your databasehttps://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database