Скачиваний:
62
Добавлен:
09.05.2014
Размер:
1.21 Кб
Скачать
package lab1;

public abstract class CoordinateQuarter implements Belonging {
protected byte quarter = Quarters.FIRST;

public CoordinateQuarter(byte value)
{
this.quarter = value;
}

protected abstract Boolean IsBelongs(Coordinate point);

public Boolean Belongs(Coordinate point){
if (!(SameQuarter(point).booleanValue()))
return Boolean.FALSE;
else
return IsBelongs(point);
}

private Boolean SameQuarter(Coordinate point) {
switch (this.quarter)
{
case Quarters.FIRST:
if ((point.GetX() >= 0) && (point.GetY() >= 0))
return Boolean.TRUE;
break;
case Quarters.SECOND:
if ((point.GetX() <= 0) && (point.GetY() >= 0))
return Boolean.TRUE;
break;
case Quarters.THIRD:
if ((point.GetX() <= 0) && (point.GetY() <= 0))
return Boolean.TRUE;
break;
case Quarters.FORTH:
if ((point.GetX() >= 0) && (point.GetY() <= 0))
return Boolean.TRUE;
break;
}
return Boolean.FALSE;
}
}
Соседние файлы в папке lab1