package MovementStrategy; public class MoveToBorder extends AbstractStrategy{ @Override protected boolean IsTargetDestinaion() { ObjectParameters objParams = GetObjectParameters(); if (objParams == null) { return false; } return objParams.RightBorder + GetStep() >= FieldWidth - GetStep() && objParams.DownBorder + GetStep() >= FieldHeight - GetStep(); } @Override protected void MoveToTarget() { ObjectParameters objParams = GetObjectParameters(); if (objParams == null) { return; } int diffX = FieldWidth - objParams.RightBorder; if (Math.abs(diffX) > GetStep()) { MoveRight(); } int diffY = FieldHeight - objParams.DownBorder; if (Math.abs(diffY) > GetStep()) { MoveDown(); } } }