/**
 * Compute various attributes and variations of strings.  Constructed
 * as part of an example for Math/CS103.
 * <p>
 * Copyright (c) 1998 Samuel A. Rebelsky.  All rights reserved.
 *
 * @version 1.0 of March 1998
 * @author Samuel A. Rebelsky
 */
public class StringManipulator {

  // +---------+-----------------------------------------------------------
  // | Methods |
  // +---------+

  /**
   * Compute the string given by removing the first letter in 
   * a string.
   */
  public String deleteFirst(String str)
  {
    return str.substring(1);
  } // deleteFirst

  /**
   * Compute the string generated by concatenating a string
   * with itself.
   */
  public String duplicate(String str)
  {
    return str + str;
  } // Duplicate(String)

  /**
   * Compute the reversal of a string (the letters in reverse
   * order).
   */
  public String reverse(String str)
  {
    String rev = "";
    // Append characters, one by one
    for (int pos = str.length()-1; pos >= 0; pos = pos - 1) {
      rev = rev + str.charAt(pos);
    } // for
    // That's it
    return rev;
  } // reverse

} // StringManipulator


