Вторая лабораторная работа
This commit is contained in:
parent
da743af9ba
commit
db827b6e0d
@ -3,7 +3,7 @@ package DoubleDeckerBus.MovementStrategy;
|
||||
public class MoveToBorder extends AbstractStrategy {
|
||||
@Override
|
||||
protected boolean IsTargetDestination() {
|
||||
ObjectParameters objParams = GetObjectParameters();
|
||||
var objParams = GetObjectParameters();
|
||||
|
||||
if (objParams == null) {
|
||||
return false;
|
||||
@ -14,20 +14,20 @@ public class MoveToBorder extends AbstractStrategy {
|
||||
}
|
||||
@Override
|
||||
protected void MoveToTarget() {
|
||||
ObjectParameters objParams = GetObjectParameters();
|
||||
var objParams = GetObjectParameters();
|
||||
|
||||
if (objParams == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int diffX = objParams.RightBorder - FieldWidth();
|
||||
var diffX = objParams.RightBorder - FieldWidth();
|
||||
if (Math.abs(diffX) >= GetStep()) {
|
||||
if (diffX < 0) {
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
|
||||
int diffY = objParams.DownBorder - FieldHeight();
|
||||
var diffY = objParams.DownBorder - FieldHeight();
|
||||
if (Math.abs(diffY) >= GetStep()) {
|
||||
if (diffY < 0) {
|
||||
MoveDown();
|
||||
|
@ -3,16 +3,16 @@ package DoubleDeckerBus.MovementStrategy;
|
||||
public class MoveToCenter extends AbstractStrategy{
|
||||
@Override
|
||||
protected boolean IsTargetDestination() {
|
||||
ObjectParameters objParams = GetObjectParameters();
|
||||
var objParams = GetObjectParameters();
|
||||
|
||||
if (objParams == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((objParams.ObjectMiddleHorizontal <= FieldWidth() / 2 &&
|
||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth() / 2) ||
|
||||
(objParams.ObjectMiddleHorizontal >= FieldWidth() / 2 &&
|
||||
objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth() / 2)) &&
|
||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth() / 2)
|
||||
||(objParams.ObjectMiddleHorizontal >= FieldWidth() / 2 &&
|
||||
objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth() / 2)) &&
|
||||
|
||||
((objParams.ObjectMiddleVertical <= FieldHeight() / 2 &&
|
||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight() / 2) ||
|
||||
@ -22,13 +22,13 @@ public class MoveToCenter extends AbstractStrategy{
|
||||
|
||||
@Override
|
||||
protected void MoveToTarget() {
|
||||
ObjectParameters objParams = GetObjectParameters();
|
||||
var objParams = GetObjectParameters();
|
||||
|
||||
if (objParams == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int diffX = objParams.ObjectMiddleHorizontal - FieldWidth() / 2;
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth() / 2;
|
||||
if (Math.abs(diffX) > GetStep()) {
|
||||
if (diffX > 0) {
|
||||
MoveLeft();
|
||||
@ -37,7 +37,7 @@ public class MoveToCenter extends AbstractStrategy{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
int diffY = objParams.ObjectMiddleVertical - FieldHeight() / 2;
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight() / 2;
|
||||
if (Math.abs(diffY) > GetStep()) {
|
||||
if (diffY > 0) {
|
||||
MoveUp();
|
||||
|
Loading…
Reference in New Issue
Block a user