Commit 94f0961

mo <mo.khan@gmail.com>
2019-06-03 03:38:11
add documentation.
1 parent 464b95b
Changed files (1)
src/Q1/ReversedSentence.java
@@ -1,8 +1,24 @@
+/**
+ * Assignment 2, COMP268 Class: ReversedSentence.java
+ *
+ * @description Provides a class to manipulating strings.
+ * @author: mo khan Student ID: 3431709
+ * @date Jun 2, 2019
+ * @version 1.0
+ */
+
 package Q1;
 
 import java.util.Scanner;
 
 public class ReversedSentence {
+  /**
+   * Replaces the every character that is in an index that is evenly
+   * divisible by 5 with the character 'z', excluding 0.
+   *
+   * @param s The input string to substitue
+   * @return The new string with the substitution.
+   */
   public static String change5thPosition(String s) {
     char[] result = new char[s.length()];
 
@@ -11,6 +27,12 @@ public class ReversedSentence {
     return new String(result);
   }
 
+  /**
+   * Combines the 2D array of character into a printable string.
+   *
+   * @param arr the two dimensional array of characters.
+   * @return a String of the combined character arrays separated by a line separator.
+   */
   public static String printChar2DArray(char[][] arr) {
     String[] strings = new String[arr.length];
 
@@ -18,6 +40,12 @@ public class ReversedSentence {
     return String.join(System.lineSeparator(), strings);
   }
 
+  /**
+   * Reverses a string.
+   *
+   * @param s the input String to reverse
+   * @return the reversed String.
+   */
   public static String reverseByCharacter(String s) {
     char[] result = new char[s.length()];
     int length = s.length();
@@ -27,6 +55,12 @@ public class ReversedSentence {
     return new String(result);
   }
 
+  /**
+   * Reverses the words in a string
+   *
+   * @param s the input string to reverse
+   * @return a string with the words in reverse order
+   */
   public static String reverseByWord(String s) {
     String[] words = s.split(" ");
     String[] result = new String[words.length];
@@ -38,10 +72,21 @@ public class ReversedSentence {
     return String.join(" ", result);
   }
 
+  /**
+   * Truncates a tring to a maximum of 80 characters.
+   *
+   * @param s the input string to truncate
+   * @return the truncated string
+   */
   public static String truncateSentence(String s) {
     return s.substring(0, Math.min(s.length(), 80));
   }
 
+  /**
+   * The entry point for the console application.
+   *
+   * @param args the commandline arguments passed to the program
+   */
   public static void main(String[] args) {
     Scanner in = new Scanner(System.in);
     String[] sentences = new String[3];