title: Homework assignment related to inheritance
body: <p>Greetings. I've completed a project for school with all but one requirement.</p>
  
  <p>The requirement is:</p>
  
  <p><strong>Notice that the SeaCreature class defines four constants for the various directions. Make sure to use them.Your code should not depend upon the specific values assigned to these constants, although you may assume they will always be of type int.</strong></p>
  
  <p>I don't see the value in this. The constant values assigned are logical and allow for easy use of Random to return a direction. If the values assigned were four non consecutive numbers that would really complicate the code.</p>
  
  <p>Below is the original SeaCreature class mentioned in the assignment, and then the code for one of my creatures that makes use of Random. Other than assigning new values to NORTH, SOUTH, EAST, WEST in each class that involves random movement, is there a cleaner way to return the cardinal directions as opposed to their values of 0-3?</p>
  
  <p>Thank you in advance for your advice, and please ask if any clarification is needed.</p>
  
  <pre><code>import java.util.*;
  /**
   * Defines the attributes and behaviors common to all SeaCreatures in order to participate
   * in the SeaCreature simulation.
   * 
   * Each SeaCreature is represented by a char.
   * Each SeaCreature can answer back its char when asked.
   * Each SeaCreature can answer its next move, NORTH, SOUTH, EAST, WEST.
   * 
   */
  
  public abstract class SeaCreature {
      private char ch;
  
      /** defined constant to facilitate random movement*/
      public static final Random rand = new Random();
  
      /** defined constant to move one unit NORTH */
      public static final int NORTH = 0;
  
       /** defined constant to move one unit SOUTH */
      public static final int SOUTH = 1;
  
       /** defined constant to move one unit EAST */
      public static final int EAST = 2;
  
       /** defined constant to move one unit WEST */
      public static final int WEST = 3;
  
  
      /**
       * Construct a SeaCreature object with the given character representation
       * @param c  the character for this SeaCreature
       */
      public SeaCreature (char c){
          ch = c;
      }
  
      /** 
       * Answers back the character representation for this SeaCreature
       * @return this SeaCreature's initial
       */
      public char getChar(){
          return ch;
      }
  
      /** Answers back the next move for this SeaCreature.
       *  Must be overridden by subclasses
       * @return NORTH, SOUTH, EAST, or WEST
       */
      public abstract int getMove(); 
  }
  </code></pre>
  
  <p>My SeaLion class:</p>
  
  <pre><code>/**
   * Defines the attributes and behaviors specific to SeaLions in order to participate 
   * in the SeaCreature simulation.
   * 
   * @author Justin Ashburn
   * @version 6/5/2011
   */
  public class SeaLion extends SeaCreature {
  
      /** defined char to represent a SeaLion*/
      private static final char SEALION = 'L';
  
      /** defined steps before SeaLion cycle repeats*/    
      private static final int CYCLE_LENGTH = 3;
  
      /** defined steps before SeaLion's first direction*/
      private static final int DIRECTION_ONE_LENGTH = 2;
  
      private int directionOne;
  
      private int count;
  
      /**
       * Construct a SeaLion object with the given character representation
       */
      public SeaLion(){
          super(SEALION);
          // establishes an initial direction
          directionOne = rand.nextInt(4);
          count = 0;        
  
      }
  
      /** Moves like the 'Knight' chess piece. ie. Picks a random direction, moves 2 times
       * in that direction, and then randomly chooses a direction perpendicular to the first
       * and moves in that direction once.
       * 
       * @return 0, 1, 2, or 3
       */
      public int getMove() {
          int direction;
          int directionTwo;
          // continues with direction one for the appropriate length
          if (count &lt; DIRECTION_ONE_LENGTH) {
              count ++;
              direction = directionOne;
          }
          // if directionOne was east or west chooses a new north or south direction for last move
          else if (count &lt; CYCLE_LENGTH &amp;&amp; directionOne &gt; 1) {
              directionTwo = rand.nextInt(2);
              direction = directionTwo;
              // resets count and establishes new direction in next cycle
              count = 0;
              directionOne = rand.nextInt(4);
          }
          // if directionOne was north or south chooses a new east or west direction for last move        
          else { 
              directionTwo = rand.nextInt(2) + 2;
              direction = directionTwo;            
              // resets count and establishes new direction in next cycle
              count = 0;           
              directionOne = rand.nextInt(4);
          }
          return direction;
      }
  }
  </code></pre>