I am implementing a simple version of Cluedo. The game has 3 types of cards: character, weapon and room. Since one card is nothing more than a line (for example, no functionality or information other than a name is stored on the card), I decided not to have a card interface, and each type extends the Card. Most likely, I had three listings in my game:
public enum Character {Scarlett, Mustard, White, Green, Peacock, Plum;} public enum Weapon {Candlestick, Dagger, LeadPipe, Revolver, Rope, Spanner;} public enum Room {Kitchen, Ballroom, Conservatory, BilliardRoom, Library, Study, Hall;}
However, there is one case where three types of cards are added together and distributed evenly to each player in the game. For example, one player may have a hand of two characters, 2 weapons and 1 room, the other player may have 3 rooms and 2 characters, so the total number of cards does not even matter which type.
And why am I wondering if there is a way to randomly select one value from all three enumerations in Java?
Or should I not do this in the first place? (Poorly designed)
source share