public class Detector extends Object implements Observer
Constructor and Description |
---|
Detector(int abscissa,
int ordinate,
Direction initialDirection,
MapArea map)
Initializes the detector with the current state of the mower.
|
Modifier and Type | Method and Description |
---|---|
int[] |
getCurrentState()
Get the current abscissa, ordinate and direction of the detector.
|
String |
getCurrentStateString()
Get the current abscissa, ordinate and direction of the detector.
|
MapArea |
getMap() |
PositionState |
getNextPositionState(WheelState wheelState)
Simulate the mower move and get the next.
|
boolean |
isAskedPositionSafe(WheelState wheelState)
Check if the next move done by the mower is safe (ie : the asked position isn't outbound and there is no mower already on it).
|
void |
update(Observable observable,
Object o)
Intercepts signal from wheels and servomotor and updates the class depending on the action
Servomotor : Updates the current direction
Wheel : update the map depending on the movement.
|
public Detector(int abscissa, int ordinate, Direction initialDirection, MapArea map)
abscissa
- initial abscissa of the mower on the area to mowordinate
- initial ordinate of the mower on the area to mowinitialDirection
- initial direction of the mowermap
- the area to mowpublic void update(Observable observable, Object o)
public boolean isAskedPositionSafe(WheelState wheelState) throws UnsafeMoveException
wheelState
- the state of the wheel (backward, forward or still)UnsafeMoveException
- if the asked box contains something different than grass.public PositionState getNextPositionState(WheelState wheelState) throws UnsafeMoveException
wheelState
- the movement to simulateUnsafeMoveException
- if the asked move make the mower going outside of the area.public int[] getCurrentState()
public String getCurrentStateString()
public MapArea getMap()
Copyright © 2016. All Rights Reserved.