Commit c918de2
Changed files (1)
src/Q2/RockPaperScissorsLizardSpock.java
@@ -45,9 +45,10 @@ public class RockPaperScissorsLizardSpock {
this.delcareRoundWinner(winner);
this.incrementWinsFor(winner);
- this.puts("Player %d has %d consecutive wins.", this.lastWinner, this.consecutiveWins);
+ if (this.lastWinner > 0)
+ this.puts("Player %d has %d consecutive wins.", this.lastWinner, this.consecutiveWins);
- if (this.consecutiveWins == 4) {
+ if (this.lastWinner > 0 && this.consecutiveWins == 4) {
this.declareWinner();
return;
}
@@ -107,6 +108,8 @@ public class RockPaperScissorsLizardSpock {
}
private void incrementWinsFor(int winner) {
+ if (winner == 0) return;
+
if (this.lastWinner == winner) {
this.consecutiveWins++;
} else if (winner > 0) {