Commit 4adea5e

mo <mo.khan@gmail.com>
2019-06-07 02:00:50
add documentation
1 parent 205bf6a
Changed files (1)
src/Q2/RockPaperScissorsLizardSpock.java
@@ -1,3 +1,11 @@
+/**
+ * Assignment 2, COMP268 Class: RockPaperScissorsLizardSpock.java
+ *
+ * @description Provide a class to play the game rock, paper, scissors, lizard spock.
+ * @author: mo khan Student ID: 3431709
+ * @date Jun 6, 2019
+ * @version 1.0
+ */
 package Q2;
 
 import java.util.*;
@@ -5,26 +13,50 @@ import java.util.*;
 public class RockPaperScissorsLizardSpock {
   private int consecutiveWins = 0;
   private int lastWinner;
-  public static final int LIZARD = 4;
-  public static final int PAPER = 2;
+
   public static final int PLAYER1 = 1;
   public static final int PLAYER2 = 2;
+
+  public static final int LIZARD = 4;
+  public static final int PAPER = 2;
   public static final int ROCK = 1;
   public static final int SCISSORS = 3;
   public static final int SPOCK = 5;
 
+  /**
+   * Returns the # of consecutive wins for the current winner.
+   *
+   * @return the # of consecutive wins for the current winner.
+   */
   public int getConsecutiveWins() {
     return this.consecutiveWins;
   }
 
+  /**
+   * Returns the id of the current winner.
+   * See PLAYER1 and PLAYER2 constants for the possible ids.
+   *
+   * @return the id of the current winner.
+   */
   public int getLastWinner() {
     return this.lastWinner;
   }
 
+  /**
+   * Returns a random integer between 1 - 5
+   *
+   * @return a random integer between 1 - 5
+   */
   public int random() {
     return new Random().nextInt(4) + 1;
   }
 
+  /**
+   * Plays the game until a winner has 4 consecutive wins.
+   *
+   * @param player1 id of player 1
+   * @param player2 id of player 2
+   */
   public void play(int player1, int player2) {
     int player1Roll = 0;
     int player2Roll = 0;
@@ -55,6 +87,12 @@ public class RockPaperScissorsLizardSpock {
     }
   }
 
+  /**
+   * Converts a integer to the equivalent name.
+   *
+   * @param i the integer to convert to a name.
+   * @return the name for the corresponding integer value.
+   */
   public static String convert(int i) {
     switch (i) {
       case ROCK:
@@ -123,6 +161,11 @@ public class RockPaperScissorsLizardSpock {
     else this.puts("The winner of this round is player %d!", winner);
   }
 
+  /**
+   * The entrypoint into the console application.
+   *
+   * @param args an argument vector that represents the command line arguments
+   */
   public static void main(String[] args) {
     RockPaperScissorsLizardSpock game = new RockPaperScissorsLizardSpock();
     game.play(RockPaperScissorsLizardSpock.PLAYER1, RockPaperScissorsLizardSpock.PLAYER2);