Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As crazy as it sounds, this is why I'd try to keep it simple and just keep each implementation separate. Sure I'd save some keystrokes having a base abstraction and whatnot, but I feel like Poker is one of those "i'll make an interface" traps that is much more complex than it originally seems


The abstraction is pretty simple, and close to that. IIRC I had base Hand object that defines a comparison routine that takes a Hand object.

The Hand object has a method that returns Card objects by index with a high to low order so subclasses can do their comparisons in either 4 or 5 card games.

The you need like a best hand method, so games like Holdem that make best 5 card hands out of 7 cards work. Then a bunch of utility functions.

It’s also useful to have your Card objects have their comparison functions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: