Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created Aug 1, 2018
Embed
What would you like to do?
Item for the Rock Paper Scissors Lizard Spock game in Java on the SSaurel's Channel
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