CSE115.Pacman
Class Position

java.lang.Object
  extended by CSE115.Pacman.Position
All Implemented Interfaces:
Constants

public class Position
extends Object
implements Constants

A class that represents a row, column pair. Particularly useful for game board that need to be displayed graphically.

Created: Fri Nov 22 12:23:16 2002

Author:
Phil Ventura, modified by Ben Robboy February 2006

Field Summary
 
Fields inherited from interface CSE115.Pacman.Constants
CELL_SIZE
 
Constructor Summary
Position(int row, int col)
          Creates a Position instance given the row and column
Position(Point pt)
          Creates a Position instance given a point.
 
Method Summary
 boolean equals(Object obj)
           
 Point getCenterLocation()
          Gives the center of the row/column space (assumes they are rectangular positions).
 int getCol()
          Returns the column of the position
 int getRow()
          Returns the row of the position
 int hashCode()
           
 Point toPoint()
          Converts the row/column position into a java.awt.Point
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Position

public Position(int row,
                int col)
Creates a Position instance given the row and column

Parameters:
row - the row for the Position
col - the column for the Position

Position

public Position(Point pt)
Creates a Position instance given a point. Converts the point to rows/columns. This method is subsuming that the cells on the board are squares.

Parameters:
pt - the point to be converted
Method Detail

getRow

public int getRow()
Returns the row of the position

Returns:
the row

getCol

public int getCol()
Returns the column of the position

Returns:
the column

getCenterLocation

public Point getCenterLocation()
Gives the center of the row/column space (assumes they are rectangular positions).

Returns:
the java.awt.Point that represents the center of the Position

toString

public String toString()
Overrides:
toString in class Object

toPoint

public Point toPoint()
Converts the row/column position into a java.awt.Point

Returns:
the point that represents the upper left hand corner of the row/column position.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object