안드로이드 개발 질문/답변
(글 수 45,052)
class Ball {
int x, y;
int rad;
int dx, dy;
int color;
int count;
int x, y;
int rad;
int dx, dy;
int color;
int count;
// 새로운 볼 생성
static Ball Create(int x, int y, int Rad) {
Random Rnd = new Random();
Ball NewBall = new Ball();
static Ball Create(int x, int y, int Rad) {
Random Rnd = new Random();
Ball NewBall = new Ball();
NewBall.x = x;
NewBall.y = y;
NewBall.rad = Rad;
do {
NewBall.dx = Rnd.nextInt(11) - 5;
NewBall.dy = Rnd.nextInt(11) - 5;
} while (NewBall.dx == 0 || NewBall.dy == 0);
NewBall.y = y;
NewBall.rad = Rad;
do {
NewBall.dx = Rnd.nextInt(11) - 5;
NewBall.dy = Rnd.nextInt(11) - 5;
} while (NewBall.dx == 0 || NewBall.dy == 0);
NewBall.count = 0;
NewBall.color = Color.rgb(Rnd.nextInt(256), Rnd.nextInt(256), Rnd.nextInt(256));
NewBall.color = Color.rgb(Rnd.nextInt(256), Rnd.nextInt(256), Rnd.nextInt(256));
return NewBall;
}
}
// 볼 이동
void Move(int Width, int Height) {
x += dx;
y += dy;
void Move(int Width, int Height) {
x += dx;
y += dy;
if (x < rad || x > Width - rad) {
dx *= -1;
count++;
}
if (y < rad || y > Height - rad) {
dy *= -1;
count++;
}
dx *= -1;
count++;
}
if (y < rad || y > Height - rad) {
dy *= -1;
count++;
}
----------------------------------------------------------------------
안녕하세요. 안드로이드 초보입니다.
안드로이드 완전 정복을 참고하면서 공부하던 중에 모르는 부분이 나와서 질문드립니다.
제가 색으로 표시한 부분인데요. static 메소드 인것 같은데. 메소드 명이 두 개인 것인가요?
특히 Ball 의 의미를 모르겠습니다. 리턴형을 표시한 것인지 헷갈리네요.
하루종일 구글링 하다가 답답해서 올려봅니다.
초보적인 질문이지만 답변 부탁드립니다.





메소드명이.. 두개인게 아니라..
알아보기 쉽게
static String Create 또는
static int Create 이렇게 보면 이해가 가시는지요 ?
Ball 이라는 클래스를 만드셔서 Create() 라는 이름의 Ball 을 하나 만드신거에요