Path: csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: Help with Deck of cards assignment and getting it to deal... Date: Sun, 03 Aug 2014 11:08:01 -0400 Organization: A noiseless patient Spider Lines: 74 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 3 Aug 2014 15:08:04 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="b896cb427f8c4d19d14880347aa9d6ce"; logging-data="6636"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18IH4+dDfnjRMWWomTnxYECMx17DBNp+AM=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.6.0 In-Reply-To: Cancel-Lock: sha1:WiV7FXg4Xnkz9Nv/x8CzIt9rZIs= Xref: csiph.com comp.lang.java.programmer:29517 On 08/01/2014 09:16 PM, Scott Dunning wrote: > Hello, I have an assignment for my summer class. FYI, I'm super new to > programming in general and this is my first time with java and it's a > summer class so it's going super fast (please be nice!) lol. No. It seems to be going slowly. The last three assignments you've brought here are rehashes. Surely by now you should have gone into interfaces and collections. Your Card class will be more easily used if it implement the java.lang.Comparable interface > Basically I started writing my code in one class, then I split it up > into a Card class and a DeckOfCards class and I now need to figure out > how to get it all to work together. I get a little confused with > calling methods sometimes, especially when separate classes are in play. PLEASE work your way through the "Learning the Java Language" trail in the Java Tutorials. Your instructor is not helping you if he hasn't insisted upon this. > I think I just need a method to deal out five cards that also tells > how many cards are left in the deck. Not necessarily. java.lang.Iterable interface comes to mind. As others have pointed out: there are many ways to accomplish an outcome. > Then get it all working together > correctly. Also, I need a toString method but I honestly do not know > how to go about that. Any help is greatly appreciated! If you could > help explain things too that would be awesome! For what? Your Card class? What are its attributes? Take out your paper and pencil, or even just put on your thinking cap and decide how you want your Card represented as a String. You already have a toString method, but it is probably not what you want. Rank[ cardRank ] + Suit[ cardSuit ] would present a fairly ugly representation, have you tried it? > I think I have > everything SO FAR correct but I could be wrong and I'm sure there are > better ways to write the code, I'll take any suggestions for a cleaner > look too. FYI, I think the prof would rather arrays then enums since > we're dealing with arrays right now. I'm gaining less respect, especially if the following is verbatim. > Here are the directions... > Design and implement a class called Card that represents a standard > playing card. Each card has a suit and a face value. Then create a class > called DeckOfCards that stores 52 objects of the Card class. Include > methods to shuffle the deck, deal a card and report the number of cards > left in the deck. The shuffle methods should assume a full deck. Create > a driver class (CardsGame) with a main method that deals five cards from > the shuffled deck, printing each card as it is dealt. Make sure to write > the appropriate constructors, getters, setters, toString and other > methods as required for both classes. Why show us a place holder? > The main class, CardsGame Class > > import java.util.Scanner; > > public class CardsGame { > public static void main (String [] args) { > > } > } >