How to operate the poker game by Java?

前端 未结 4 1808
Happy的楠姐
Happy的楠姐 2021-01-16 17:44

I’ve learned Java for 1 month. This time, I’d like to create a poker game. There are two questions about my program. I hope somebody can help me to fix it.

4条回答
  •  被撕碎了的回忆
    2021-01-16 18:26

    What you should be considering for this sort of classification is Enums:

    public enum Suit {
      Hearts, Spades, Diamonds, Clubs;
    }
    public enum Card {
      A, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K;
    }
    

    This benefits your situation since enums can be assigned value easily, to whatever you like, and then they can be compared based on this value. In fact, the Java documentation provides a card game for the introduction to enums.

提交回复
热议问题