Created
August 1, 2018 10:15
-
-
Save ssaurel/f09cba5010062287703f36bbe5c57b0e to your computer and use it in GitHub Desktop.
Item for the Rock Paper Scissors Lizard Spock game in Java on the SSaurel's Channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Item { | |
ROCK, PAPER, SCISSORS, LIZARD, SPOCK; | |
public List<Item> losesTo; | |
public boolean losesTo(Item other) { | |
return losesTo.contains(other); | |
} | |
static { | |
SCISSORS.losesTo = Arrays.asList(ROCK, SPOCK); | |
ROCK.losesTo = Arrays.asList(PAPER, SPOCK); | |
PAPER.losesTo = Arrays.asList(SCISSORS, LIZARD); | |
SPOCK.losesTo = Arrays.asList(PAPER, LIZARD); | |
LIZARD.losesTo = Arrays.asList(SCISSORS, ROCK); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment