first try

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 16 19:53:08 PDT 2017


I remember this game from many many years ago. :)

On 03/16/2017 05:35 PM, Philip Miess wrote:
> This is my first 100+ line D program.
> https://gitlab.com/pmiess/101gamesDlangComputerGames/blob/master/
> aceyducy.d
> Its a translation/refactor of aceyducy from 101 basic programs.
> Could someone look over it and see if I've made any glaring mistakes.
> Suggestions are welcome also.
>
> Thanks,
> Phil
>

It looks pretty good to me.

- All capital letters? Yuck! :)

- Typo: DOLLERS

- It's better to declare and define variables at the same time:

   int bet = inputInt( "\nWHAT IS YOUR BET");
   int card1 = uniform(2, 15, rnd);

That way, you can make the variables const if you care:

   const bet = inputInt( "\nWHAT IS YOUR BET");
   const card1 = uniform(2, 15, rnd);

- I liked the functional style of programming like stakes goes into 
aceyducyHand and then comes out as return value.

- I've also learned something: It was interesting how getBet() and 
aceyducyGames() are handled recursively.

Ali



More information about the Digitalmars-d-learn mailing list