The new method does not test for a base case.
I can't allow a chapter to go by without reminding you of this: A recursive definition has two parts:
Our seriously wrong drawStar()
method does not test
for a base case. Look at it again:
// Seriously Wrong Method
//
private void drawStar( int x, int y, int size )
{
int endX, endY ;
// Six lines radiating from (x,y)
for ( int i = 0; i<6; i++ )
{
endX = x + (int)(size*Math.cos( (2*Math.PI/6)*i ));
endY = y - (int)(size*Math.sin( (2*Math.PI/6)*i ));
graph.drawLine( x, y, endX, endY );
drawStar( endX, endY, size/3 ) ;
}
}
Everytime it is called, it calls itself again. It does not test for a case where it can return to its caller.
(You might want to think about this: ) What base case should this method test for?