Скачиваний:
71
Добавлен:
09.05.2014
Размер:
1.07 Кб
Скачать
class PointInArea extends Point
implements IfaceArea {
private enum Quarters { first , second, third, fourth };

private Quarters qrtr;

public PointInArea (double x_coord) {
this (x_coord, x_coord);
}

public PointInArea (double x_coord, double y_coord) {
super (x_coord, y_coord);
if (x_coord >= 0)
if (y_coord >= 0)
qrtr = Quarters.first;
else qrtr = Quarters.fourth;
else if (y_coord >= 0)
qrtr = Quarters.second;
else qrtr = Quarters.third;
}

public boolean isInArea (double R) {
switch (qrtr) {
case second:
if (x >= -R/2 && y <= R)
return true;
break;
case third:
if (y >= (-x - R))
return true;
break;
case fourth:
if ((Math.pow(x, 2) + Math.pow(y, 2)) <= Math.pow(R, 2))
return true;
break;
}
return false;
}
}
Соседние файлы в папке java.lab1