I have created a class named DeckOfCard.java which creates a deck of
cards (using a class named Card.java) and then shuffles it. This class includes a method to deal
cards from the created, shuffled deck one at a time. What I want to do is split out, into a separate class, the shuffle method. I know that I�m missing something simple, but I keep getting a compile error. Here, first, is the one-file (single class) code for Card.java:
Here is the DeckOfCards.java code, the single-class create-shuffle-deal class:
My question is this: If I want to set up Shuffle.java as a separate class and use its method to shuffle the deck created in DeckOfCards, how do I have to configure Shuffle.java and how do I have to call its shuffle method? Here is what I wrote for a shuffle class:
Here is what I wrote for a
test class (with the non-working call commented):
When I comment out the shuffle method in the original code and then run the Test.java with the Shuffle.riffle( ) call, I get the following error:
Test.java:10: riffle(Card[]) in Shuffle cannot be applied to (DeckOfCards)
Bottom line: splitting out the shuffle code to a separate class and calling its method, named riffle( ), from test is a no-go. I know it is something simple, but its obviousness escapes me.
[ December 02, 2005: Message edited by: Bill Stanard ]
[ December 05, 2005: Message edited by: Bill Stanard ]
[ December 05, 2005: Message edited by: Bill Stanard ]