movingregion
Class LineWA

java.lang.Object
  |
  +--movingregion.LineWA
All Implemented Interfaces:
java.lang.Comparable

public class LineWA
extends java.lang.Object
implements java.lang.Comparable

This class is meant to store lines and the angle between them. The class itself stores a single point and an angle. The point is the starting point of the line, and the angle is the angle between the two lines that meet at that point. To actually store lines, the LineWA objects must be stored in a list. In such a list, the element after a given element stores the coordinates of the end point of the line.


Field Summary
 double angle
           
 int x
           
 int y
           
 
Constructor Summary
LineWA()
          Constructor without parameters.
LineWA(int xp, int yp)
          This constructor initializes the angle to 0.
LineWA(int xp, int yp, double a)
          This constructor initializes all variables to given values.
LineWA(LineWA original)
          This constructor initializes this object to be an exact copy of another LineWA object.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares two LineWA objects.
 boolean equals(java.lang.Object obj)
          Tests equality of two LineWA objects.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public int x

y

public int y

angle

public double angle
Constructor Detail

LineWA

public LineWA()
Constructor without parameters. This constructor initializes all variables to 0.

LineWA

public LineWA(int xp,
              int yp)
This constructor initializes the angle to 0.
Parameters:
xp - The x-coordinate of the point to be stored in this object.
yp - The y-coordinate of the point to be stored in this object.

LineWA

public LineWA(int xp,
              int yp,
              double a)
This constructor initializes all variables to given values.
Parameters:
xp - The x-coordinate of the point to be stored in this object.
yp - The y-coordinate of the point to be stored in this object.
a - The angle between the last and next lines.

LineWA

public LineWA(LineWA original)
This constructor initializes this object to be an exact copy of another LineWA object.
Parameters:
original - The LineWA object to be copied.
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compares two LineWA objects. This uses angles for comparison, NOT position. Therefore, the ordering of LineWA is not consistent with equals. This function is an implementation of the Comparable interface.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The object that this object should be compated to.
Returns:
1 if the angle of o is less than the angle of this object, 0 if they are equal, and -1 if the angle of o is greater than the angle of this object.

equals

public boolean equals(java.lang.Object obj)
Tests equality of two LineWA objects. These objects are equal if they have the same position.
Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to be compated to this object.
Returns:
TRUE if obj is a LineWA with the same position as this one and FALSE otherwise.