de.uni_paderborn.robots.robot.group9
Class ItemTypeMatcher

java.lang.Object
  |
  +--de.uni_paderborn.robots.robot.group9.ItemTypeMatcher
All Implemented Interfaces:
MapItemMatcher

public class ItemTypeMatcher
extends java.lang.Object
implements MapItemMatcher

Implementation of MapItemMatcher, that searches for the shortest path to a map item with a specified type


Field Summary
(package private)  short type
          The type to search for
 
Constructor Summary
(package private) ItemTypeMatcher(short type)
          Creates a new ItemTypeMatcher that searches for map items with the specified type
 
Method Summary
 boolean equals(java.lang.Object otherMapItemMatcher)
          Does this ItemTypeMatcher search for the same map items as the specified object?
 boolean finished(MapItem mapItem)
          Because type MapItemMatcher only searches for one map item, whenever the first item is found, the search should immediately stop.
 boolean matches(MapItem mapItem)
          Matches the item
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

type

short type
The type to search for
Constructor Detail

ItemTypeMatcher

ItemTypeMatcher(short type)
Creates a new ItemTypeMatcher that searches for map items with the specified type
Parameters:
type - the type to search for. This may be
  • MapItem.TELEPORT
  • MapItem.WELL
  • MapItem.EXIT
  • MapItem.CARD
  • MapItem.SLEEPING_ROBOT
  • MapItem.UNKNOWN_REACTABLE
Probably also works for MapItem.EMPTY, MapItem.WALL, MapItem.ROBOT and MapItem.UNKOWN_ITEM, however the sense of these seems quite limited.
Method Detail

matches

public boolean matches(MapItem mapItem)
Matches the item
Specified by:
matches in interface MapItemMatcher
Parameters:
mapItem - the map item to check
Returns:
true if the type of the specified map item is equal to the type to be searched for

finished

public boolean finished(MapItem mapItem)
Because type MapItemMatcher only searches for one map item, whenever the first item is found, the search should immediately stop.
Specified by:
finished in interface MapItemMatcher
Returns:
always true

equals

public boolean equals(java.lang.Object otherMapItemMatcher)
Does this ItemTypeMatcher search for the same map items as the specified object?
Overrides:
equals in class java.lang.Object
Parameters:
otherMapItem - some object, preferably a MapItemMatcher, however it is no harm if something else is passed.
Returns:
true if the MapItemMatchers search for the same thing