Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: proper use of .java files (layout) Date: Sun, 16 Dec 2012 08:24:21 -0800 Organization: A noiseless patient Spider Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 16 Dec 2012 16:24:25 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="61282af8d6595e8d991edb5ac03d6e00"; logging-data="9159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+vu85+ivdH5J9CrdFRX0W/LNJCeRz1F4=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Cancel-Lock: sha1:Q+fhBfXGZCOz+B/KD+/vxy53DBI= Xref: csiph.com comp.lang.java.programmer:20381 On 12/16/2012 7:38 AM, infinitum3d@hotmail.com wrote: > I'm trying to figure out the best way to layout a java program. > Should I put each object into its own .java file? If I'm making a > card game, that would be 52 .java files. Is that crazy? Normal? What Arne and Robert said. In this case you want a single class with two fields, one for suit and one for face value. (You could encode both the suit and the value in to a single field. However this sort of space saving is usually counter-productive, unless you're absolutely sure it's needed.) public class PlayingCard { private final int value; // Ace = 1 private final Suit suit; public static enum Suit { HEARTS, CLUBS, SPADES, DIAMONDS } ... ect.... } You will of course have to make 52 instances of that class. Do that at runtime, don't try to make 52 files.