This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Kelly A couple of things about your code: Your shuffle method is inside of your main method. You need to move it out of there and then give it a return type. When you move it out you'll get compiler errors because then your shuffle method wont be able to see the cards array which is declared locally to your main method. You can either pass the cards array to shuffle 'shuffle(cards);' or make cards a static variable of the deck class. (Every deck object would be the same right? Unless you are going to expand this to cover things like euchre decks, pinnochle decks, etc - in that case make Deck an abstract class then you'd subclass it with NormalDeck, EuchreDeck etc). In yoour case it's probably easier to just consider this a normal deck, in which case it'll always have 52 cards. So you can make cards a static class variable, shuffle could then be a static method that shuffles your cards. You'll also have to move DECKSIZE out of main too. If you do those things then you can shorten your main method and create a static initializer block to fill your cards array. Then, in main, all you'd have to do is call your methods to manipulate your Deck. Check this out, I changed some of your code to show what I mean...
some people don't like having their code changed, sorry if it upsets you, but I'm not the best at explaining what I'm saying sometimes, so it's easier to show you. If this is a school assignment you might be limited to certain things the teacher told you you had to do, if thats the case then ignore anything I wrote that you're not allowed to do. hope this helps, if you have any questions let me know... Dave
I guess the reason you get that error is because your shuffle-method doesn't have a returntype (look at Dave's code, he's put one in). Remember, only constructors have no returntype, all other methods must claim to return something, even if that something is "void". /Mike