java 재귀함수 시퀀스 다이어그램

이번에 인턴 사원 멘토링을 맡게 되면서 교육을 진행하고 있는데 재귀함수에 대해서는 잘 이해를 못하는 것 같아 시퀀스 다이어그램을 그려보았다.

재귀함수를 어떻게 그리면 좋을까 생각한 끝에 아래와 같은 결과물이 나왔는데 인턴 사원이 잘 이해할 수 있을랑가 모르겠다.


[시퀀스 다이어그램]

etc-image-0



package algorithm;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import java.io.File;
import org.junit.Test;
/**
* @FileName : RecursiveTest.java
* @Project : test_project
* @Date : 2013. 7. 5.
* @작성자 : 이남규
* @프로그램설명 :
*/
public class RecursiveTest {
/**
* <pre>
* recursiveFile
* 디렉토리 안에 있는 파일 갯수 추출
* <pre>
* @param file
* @param totalCnt
* @return
*/
public int recursiveFile(File file) {
// 파일인 경우
if (file.isFile()) {
return 1;
}
int totalCnt = 0;
String[] fileList = file.list();
for (String childFile : fileList) {
totalCnt += recursiveFile(new File(file, childFile));
}
return totalCnt;
}
@Test
public void test() {
assertThat(3, is(recursiveFile(new File("E:\\test\\recursive"))));
}
}