0

I noticed that interviewers often ask to design a poker game in either c++ or java. There could be many ways to do that, so I was wondering if anyone could give me a good template answer.

Thanks

Bob
  • 10,741
  • 27
  • 89
  • 143
  • 4
    You're probably going to have to ask a more specific question. As it stands, the question is overly broad and likely to get closed. Perhaps you've thought through a couple of designs *you* might use, and have specific questions about a particular aspect of those designs? – Rob Hruska Mar 22 '11 at 22:59
  • Good interviewers don't ask questions that can answered using a stencil or template. I prefer to have people who think working for me; otherwise I'd write a program to do it! – Thomas Matthews Mar 22 '11 at 23:21

3 Answers3

2

I'd start with classes like Card and Deck and Hand and Player. I'd tell them where I intended to encapsulate the rules for determining winning hands and how I'd evaluate them.

How specific would you like to be?

I don't find "design a poker playing system" to be very common interview question. As a matter of fact, I've never been asked such a thing in an interview. Are you applying for jobs at casinos? That might explain it....

duffymo
  • 305,152
  • 44
  • 369
  • 561
2

I would stay away from template answers. The primary reason for this interview question is to find out how you think and how you incorporate the sum of your experiences. There is no correct answer for this interview question; but there could be many wrong ones.

Not only do you need to know how to design, but also be prepared to justify your design decisions. For example, why would you use Object Oriented Design versus procedural? Have you considered project scheduling? What platforms?

If you feel like panicking, you probably need to study more have real-world experience.

Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154
1

I saw an interesting way to represent a deck of cards in a Computer Science book. You create an array/list of numbers 1-52. Then you say the numbers 1-13 represent spades, 14-27 represent hearts, etc. Then you can use modulo to easily determine what suit the card is and from there what the card is itself.

SteVwonder
  • 175
  • 1
  • 1
  • 8
  • 3
    An unwarranted hack for micro-optimization. If a program needs tricks like this to improve performance, I'd say scrap it and redesign. I prefer programs that are readable, correct and easy to maintain than ones that use hacks to save a little space or time. – Thomas Matthews Mar 22 '11 at 23:19