ball world를 구성하는 기본 요소
package com.nhnacademy;
public class Ball {
private int x;
private int y;
private int radius;
public Ball(int x, int y, int radius) {
if(radius <= 0) {
throw new IllegalArgumentException("반지름은 0보다 커야합니다.");
}
if( (x + (long)radius > Integer.MAX_VALUE)
|| (x - (long)radius > Integer.MAX_VALUE)
|| (y + (long)radius > Integer.MAX_VALUE)
|| (y - (long)radius > Integer.MAX_VALUE)) {
throw new IllegalArgumentException("공이 정수공간을 벗어납니다.");
}
this.x = x;
this.y = y;
this.radius = radius;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getRadius() {
return radius;
}
@Override
public String toString() {
return "(" + getX() + "," + getY() + "," + getRadius() + ")";
}
}