public class GridManager extends java.lang.Object implements IGridManager
Classes that employ this GridManager are expected to translate between their own geometric coordinate system and 0-based indexes used within this class.
Constructor and Description |
---|
GridManager(int size)
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addComponent(java.lang.String name,
int location)
Adds a Component to the specified location in the
grid.
|
java.lang.Object |
clone()
Deep copies and returns a newly instantiated object.
|
void |
copy(GridManager otherObject)
Deep copies the contents of the object from another object.
|
boolean |
equals(java.lang.Object otherObject)
Compares the contents of objects and returns true
if they are identical, otherwise returns false.
|
java.util.List<java.lang.Integer> |
getComponentLocations(java.lang.String name)
Gets all the locations occupied by a Component in
the grid.
|
java.lang.String |
getComponentName(int location)
Gets the name of the Component in the specified
grid location.
|
int |
hashCode()
Returns the hashCode of the object.
|
boolean |
removeComponent(int location)
Dissociates the Component at a specified location
with that location.
|
boolean |
removeComponent(java.lang.String name)
Dissociates the Component with all locations that
it currently occupies.
|
public GridManager(int size)
size
- The maximum index supported plus 1.public java.lang.String getComponentName(int location)
getComponentName
in interface IGridManager
location
- The index of the location in the grid being managed.null
if no name is found.public java.util.List<java.lang.Integer> getComponentLocations(java.lang.String name)
getComponentLocations
in interface IGridManager
name
- The name of the Component to search for.public boolean addComponent(java.lang.String name, int location)
addComponent
in interface IGridManager
name
- The name of the Component to add to the grid.location
- The location index in which to put the Component.public boolean removeComponent(int location)
removeComponent
in interface IGridManager
location
- The index of the Component to remove.public boolean removeComponent(java.lang.String name)
removeComponent
in interface IGridManager
name
- The name of the Component to remove from the GridManager.public boolean equals(java.lang.Object otherObject)
equals
in class java.lang.Object
otherObject
- The object to compare against.public int hashCode()
Returns the hashCode of the object.
hashCode
in class java.lang.Object
public void copy(GridManager otherObject)
Deep copies the contents of the object from another object.
otherObject
- The other object to copy the contents of.public java.lang.Object clone()
Deep copies and returns a newly instantiated object.
clone
in class java.lang.Object