Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > proper use of .java files (layout)

Reply
Thread Tools

proper use of .java files (layout)

 
 
Arne Vajhøj
Guest
Posts: n/a
 
      12-18-2012
On 12/17/2012 9:22 PM, Gene Wirchenko wrote:
> On Mon, 17 Dec 2012 20:58:59 -0500, Arne Vajhøj <>
> wrote:
>
>> On 12/17/2012 1:28 PM, Lew wrote:

>
> [snip]
>
>>> If you hard-code certain assumptions, e.g., that there are 52 cards in the deck,
>>> your program will be unable to model many games.

>>
>> I would argue that a deck is always 52 cards, but that some
>> games use more than one deck.

>
> Some games do not use all of the deck; some include one or more
> jokers. See the section "Modified Deck" in
> http://boardgamegeek.com/wiki/page/S...ing_Card_Games
> for several examples.


Jokers has already been discussed.

I would not change the definition of deck because some
games does not use all cards in a deck.

public interface Game {
...
public List<Card> cardsUsed();
}

Arne


 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      12-18-2012
markspace <-@.> writes:
>I was actually thinking about that. I don't like the idea of trying to
>encode most of the values of a face card as enums.


I do not like the idea of designing a card game /before/
I know exactly /which/ card game it is at all. I need to
know the rules of this card game and what exactly has to be
programmed (e.g., human players or also computer [AI]
players?). Only then I start to design.

But often not even then do I do a beforehand OOD. Instead,
I start out procedurally, using OOP only where it is obvious.
Then I start to see OO patterns in the procedural code,
so I then refactor into OOD and eventually arrive at an
»object-oriented program«.

But this is also a question of experience: If I would
already have written similar games, I might be able to
OOD a larger part of the program up-front.

 
Reply With Quote
 
 
 
 
Gene Wirchenko
Guest
Posts: n/a
 
      12-18-2012
On Mon, 17 Dec 2012 21:28:07 -0500, Arne Vajhøj <>
wrote:

>On 12/17/2012 9:18 PM, Gene Wirchenko wrote:
>> On Mon, 17 Dec 2012 20:55:21 -0500, Arne Vajhøj <>
>> wrote:
>>
>> [snip]
>>
>>> 13 distinct values with an order but no numeric values
>>> seems a perfect fit for enum to me.

>>
>> An enum does not guarantee an order.

>
>In the Java I use enums have a compareTo method.


And how would you handle the aces?

A-6-4-3-2 is ace high, but A-5-4-3-2 is actually 5-4-3-2-A (a
five-high straight).

Human systems can be remarkably exceptional if I may use the word
in the sense of "having an exception".

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      12-18-2012
On 12/18/2012 12:10 AM, Gene Wirchenko wrote:
> On Mon, 17 Dec 2012 21:28:07 -0500, Arne Vajhøj <>
> wrote:
>
>> On 12/17/2012 9:18 PM, Gene Wirchenko wrote:
>>> On Mon, 17 Dec 2012 20:55:21 -0500, Arne Vajhøj <>
>>> wrote:
>>>
>>> [snip]
>>>
>>>> 13 distinct values with an order but no numeric values
>>>> seems a perfect fit for enum to me.
>>>
>>> An enum does not guarantee an order.

>>
>> In the Java I use enums have a compareTo method.

>
> And how would you handle the aces?
>
> A-6-4-3-2 is ace high, but A-5-4-3-2 is actually 5-4-3-2-A (a
> five-high straight).


In some "high-low" games, A-5-4-3-2 can be both a
five-high straight *and* an Ace with four low cards,
possibly winning both the "high" and "low" shares of
the pot.

--
Eric Sosman
d
 
Reply With Quote
 
infinitum3d@hotmail.com
Guest
Posts: n/a
 
      12-18-2012
Wow! Lots of great discussion going on here.

This in no way, shape, or form negates or takes away anything from any of the wonderful comments already posted, but let me add some details to help clarify the original post;

As stated in the OP, I consider a deck to be 52 cards with 4 suits. Those suits are Hearts, Clubs, Diamonds, Spades. Aces could be valued as 1 or 11.

I'm not exactly sure what card game I will be programming at this time. I've never done a card game before, so I will start with something extremely minor, perhaps a Memory style game where you have 52 cards face down in 4 rows of 13. You turn them over two at a time and hope for a matching pair (byface/value, ie. 2 of Hearts and 2 of Spades). Maybe I'll start even smaller, with only 16 cards.

Eventually I would like to progress to something like Magic: The Gathering (or the Alchemy droid app) with several hundreds of cards, with various values and abilities.

Thank you all again for your comments. They are extremely helpful.

I3D
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      12-18-2012
On 12/18/2012 10:05 AM, lipska the kat wrote:
> On 18/12/12 14:32, wrote:
>
>> I'm not exactly sure what card game I will be programming at this time.

>
> Interesting, what do our procedural programmer(s) make of this then.
> The OP isn't sure what game he will be programming ....
>
> I suggest you start writing some code


He doesn't know what he wants to do, yet your advice is
"start writing some code?"

Ye flippin' gods.

--
Eric Sosman
d
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      12-18-2012
On 12/18/2012 11:27 AM, lipska the kat wrote:
> On 18/12/12 16:07, Eric Sosman wrote:
>> On 12/18/2012 10:05 AM, lipska the kat wrote:
>>> On 18/12/12 14:32, wrote:
>>>
>>>> I'm not exactly sure what card game I will be programming at this time.
>>>
>>> Interesting, what do our procedural programmer(s) make of this then.
>>> The OP isn't sure what game he will be programming ....
>>>
>>> I suggest you start writing some code

>>
>> He doesn't know what he wants to do, yet your advice is
>> "start writing some code?"
>>
>> Ye flippin' gods.

>
> Yes, start writing code
> What do you suggest he does, Sit there twiddling his fingers.
>
> I bet you have a pre-meeting meeting to discuss what to discuss in the
> meeting don't you. Ye gods and little Indians, I've battled with the
> likes of you all my professional life. I always deliver though because I
> get code down and learn from it.
>
> Write code, make mistakes, refactor, reiterate ... LEARN
>
> Or sit on your hands lamenting your inability to get past the first
> obstacle


The nice part about working with no goal in mind
is that you can declare victory whenever it suits you.
Don't raise the bar: Hide it!

--
Eric Sosman
d
 
Reply With Quote
 
Gene Wirchenko
Guest
Posts: n/a
 
      12-18-2012
On Tue, 18 Dec 2012 08:53:58 -0500, Eric Sosman
<> wrote:

>On 12/18/2012 12:10 AM, Gene Wirchenko wrote:


[snip]

>> And how would you handle the aces?
>>
>> A-6-4-3-2 is ace high, but A-5-4-3-2 is actually 5-4-3-2-A (a
>> five-high straight).

>
> In some "high-low" games, A-5-4-3-2 can be both a
>five-high straight *and* an Ace with four low cards,
>possibly winning both the "high" and "low" shares of
>the pot.


Right. I have rarely ever played high-low and forgot about them.
Does anyone else have an exception to ambush us with? <g>

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
Gene Wirchenko
Guest
Posts: n/a
 
      12-18-2012
On Tue, 18 Dec 2012 16:27:28 +0000, lipska the kat
<> wrote:

>On 18/12/12 16:07, Eric Sosman wrote:
>> On 12/18/2012 10:05 AM, lipska the kat wrote:
>>> On 18/12/12 14:32, wrote:
>>>
>>>> I'm not exactly sure what card game I will be programming at this time.
>>>
>>> Interesting, what do our procedural programmer(s) make of this then.
>>> The OP isn't sure what game he will be programming ....
>>>
>>> I suggest you start writing some code

>>
>> He doesn't know what he wants to do, yet your advice is
>> "start writing some code?"
>>
>> Ye flippin' gods.

>
>Yes, start writing code
>What do you suggest he does, Sit there twiddling his fingers.


I suggest that designing comes before writing code.

>I bet you have a pre-meeting meeting to discuss what to discuss in the
>meeting don't you. Ye gods and little Indians, I've battled with the


Straw man.

No, but I do work out what is needed in terms of features and
then work out the sorts of entities that I will need to implement
these.

>likes of you all my professional life. I always deliver though because I
>get code down and learn from it.


I write code, too, but the measure of a system is not just the
code. Its organisation counts for a lot.

>Write code, make mistakes, refactor, reiterate ... LEARN


Or one can design and make far fewer mistakes.

>Or sit on your hands lamenting your inability to get past the first obstacle


Another straw man.

>jeez


Sincerely,

Gene Wirchenko
 
Reply With Quote
 
Joshua Cranmer
Guest
Posts: n/a
 
      12-18-2012
On 12/18/2012 11:13 AM, Gene Wirchenko wrote:
> On Tue, 18 Dec 2012 08:53:58 -0500, Eric Sosman
> <> wrote:
>
>> On 12/18/2012 12:10 AM, Gene Wirchenko wrote:

>
> [snip]
>
>>> And how would you handle the aces?
>>>
>>> A-6-4-3-2 is ace high, but A-5-4-3-2 is actually 5-4-3-2-A (a
>>> five-high straight).

>>
>> In some "high-low" games, A-5-4-3-2 can be both a
>> five-high straight *and* an Ace with four low cards,
>> possibly winning both the "high" and "low" shares of
>> the pot.

>
> Right. I have rarely ever played high-low and forgot about them.
> Does anyone else have an exception to ambush us with? <g>


In the card game "capitalism," the highest card is a 2. ISTR a variant
where the highest card is a 3 as well....

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the proper way to use SocketChannel.finishConnect()? - Java 1 07-26-2005 01:03 AM
Proper use of assertions Razvan Java 5 10-08-2004 02:39 PM
Proper way to use an imported constant under 'use strict'? H. Wade Minter Perl Misc 8 04-25-2004 12:58 AM
Proper (vs. desirable) use of Graphics object Wolfgang Java 7 01-23-2004 05:42 PM
Proper use of CharsetDecoder? Harald Kirsch Java 1 08-05-2003 07:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57