summaryrefslogtreecommitdiff
path: root/src/Q2
diff options
context:
space:
mode:
authormo <mo.khan@gmail.com>2019-06-06 20:45:22 -0600
committermo <mo.khan@gmail.com>2019-06-06 20:45:22 -0600
commita7f31ad3fec79bf125200bae9ffee2e25c0ae974 (patch)
treea06d2fe7aa89b563950b8838ec64dff785161e00 /src/Q2
parent70d3f203cf1cf059f5545fd0e75dd2d567f984e8 (diff)
create program profile for Q2
Diffstat (limited to 'src/Q2')
-rw-r--r--src/Q2/README.md82
-rw-r--r--src/Q2/RockPaperScissorsLizardSpock.java4
2 files changed, 84 insertions, 2 deletions
diff --git a/src/Q2/README.md b/src/Q2/README.md
index db91fec..fa04c54 100644
--- a/src/Q2/README.md
+++ b/src/Q2/README.md
@@ -33,6 +33,88 @@ Rule 10: Rock breaks scissors
```
2. Description of the Code:
+
+The main game loop can be found in `main`. This will loop until a winner
+has won at least 4 consecutive times.
+
+The `Random` class is used to generate a pseudo random number between
+0 - 4. To keep the numbers between 1 - 5, I have incremented this value
+by 1.
+
+The `play` method prints out the choice for both players, then
+determines the winner and adjusts the last winner and consecutive wins
+fields based on the winner.
+
3. Errors and Warnings:
+
+When a tie occurs, I assume the previous winner remains the current
+winner.
+
+This program does not require any user input so the possibilities
+remains low. A possible condition that can occur is an infinite loop due
+to the random number generator producing results that does not allow a
+single player to win 4 consecutive times. One way to handle this
+scenario, is to set a maximum number of rounds that can be played. I
+chose not to implement this.
+
4. Sample Input and Output:
+
+An example of a short game:
+
+```bash
+Starting a new game of Rock, paper, scissors, lizard, spock...
+
+Round: 1
+--------------------------------------
+Player 1: scissor
+Player 2: paper
+Player 1 has 1 consecutive wins.
+
+Round: 2
+--------------------------------------
+Player 1: scissor
+Player 2: lizard
+Player 1 has 2 consecutive wins.
+
+Round: 3
+--------------------------------------
+Player 1: rock
+Player 2: lizard
+Player 1 has 3 consecutive wins.
+
+Round: 4
+--------------------------------------
+Player 1: paper
+Player 2: rock
+Player 1 has 4 consecutive wins.
+
+**************************************
+ The winner is player 1!
+**************************************
+```
+
+An example of a longer game:
+```bash
+...
+Round: 72
+--------------------------------------
+Player 1: paper
+Player 2: paper
+Player 1 has 3 consecutive wins.
+
+Round: 73
+--------------------------------------
+Player 1: rock
+Player 2: scissor
+Player 1 has 4 consecutive wins.
+
+**************************************
+ The winner is player 1!
+**************************************
+```
+
5. Discussion:
+
+I chose to print additional information to the console to make it
+easier to see how many rounds were played and to ensure that the
+correct winner is determined.
diff --git a/src/Q2/RockPaperScissorsLizardSpock.java b/src/Q2/RockPaperScissorsLizardSpock.java
index ec3934d..1715c4e 100644
--- a/src/Q2/RockPaperScissorsLizardSpock.java
+++ b/src/Q2/RockPaperScissorsLizardSpock.java
@@ -53,8 +53,8 @@ public class RockPaperScissorsLizardSpock {
/**
* Plays the game until a winner has 4 consecutive wins.
*
- * @param player1 id of player 1
- * @param player2 id of player 2
+ * @param player1 the choice made by player 1
+ * @param player2 the choice made by player 2
*/
public void play(int player1, int player2) {
this.puts("Player 1: %s", convert(player1));