Problem Statement
You are playing Rock-Paper-Scissor with your friend. It is a game that works as follows:
- 1) You say aloud Rock...Paper...Scissor...
- 2) Then you make your hand visible to your opponent in the shape of a either a rock, paper, or scissor
- 3) Rock beats Scissor, Paper beats Rock, Scissor beats Paper, and all other combinations are draws
Create a class RockPaper that contains the method maxWins, which takes a String moves and returns an int that represents the maximum number of times your friend can win.
Definition
- Class:
- RockPaper
- Method:
- maxWins
- Parameters:
- String
- Returns:
- int
- Method signature:
- int maxWins(String moves)
- (be sure your method is public)
Constraints
- moves will have length between 3 and 48 inclusive
- moves will only contain the characters 'R','P', and 'S' (quotes for clarity)
- moves will have length divisible by 3
Examples
"RRRPPPSSS"
Returns: 9
This is the example stated above."RPSRPSRPS"
Returns: 3
Regardless of what moves your opponent makes he will always win 3 times."RRRRPPPPS"
Returns: 7
If your opponent plays "PPPSSSSSS" he will beat you 7 times."SSRRPPSSRRPP"
Returns: 8
"SRPRRRPSSSSPSSS"
Returns: 11