Created
April 9, 2018 23:39
-
-
Save Ge0rg3/1c5818f70a8a86b324cf45ab884fc085 to your computer and use it in GitHub Desktop.
A simple Rock-Paper-Scissors function created for https://bit.ly/2GNZcZp
This file contains hidden or 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
import java.util.Arrays; | |
public class Kata { | |
public static String rps(String p1, String p2) { | |
String OneWin = "Player 1 won!"; | |
String TwoWin = "Player 2 won!"; | |
String Draw = "Draw!"; | |
if (p1.equals("rock")) { | |
switch(p2) { | |
case "scissors": return OneWin; | |
case "paper": return TwoWin; | |
default: return Draw; | |
}} else if (p1.equals("paper")) { | |
switch(p2) { | |
case "scissors": return TwoWin; | |
case "rock": return OneWin; | |
default: return Draw; | |
}} else { | |
switch(p2) { | |
case "paper": return OneWin; | |
case "rock": return TwoWin; | |
default: return Draw; | |
}} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment