@@ -14,12 +14,14 @@ public static void main(String[] args)
1414 Tortoise .setSpeed (10 );
1515 Tortoise .getBackgroundWindow ().setBackground (PenColors .Yellows .Goldenrod );
1616 int branchLength = 65 ;
17- Tortoise .setX (175 );
18- Tortoise .setY (350 );
19- drawBranch (branchLength );
20- drawBranch (branchLength - 1 );
21- Tortoise .setX (450 );
22- Tortoise .setY (350 );
17+ drawTree (branchLength , 170 , 350 );
18+ branchLength = 60 ;
19+ drawTree (branchLength , 450 , 350 );
20+ }
21+ private static void drawTree (int branchLength , int x , int y )
22+ {
23+ Tortoise .setX (x );
24+ Tortoise .setY (y );
2325 drawBranch (branchLength );
2426 drawBranch (branchLength - 1 );
2527 }
@@ -49,9 +51,9 @@ public static void drawShorterBranches(int branchLength)
4951 public static void adjustColor (int branchLength )
5052 {
5153 HashMap <Integer , Color > colors = new HashMap <Integer , Color >();
52- colors .put (30 , PenColors .Greens .Olive );
53- colors .put (40 , PenColors .Browns .Sienna );
54- colors .put (50 , PenColors .Browns . SaddleBrown );
54+ colors .put (51 , PenColors .Greens .Olive );
55+ colors .put (54 , PenColors .Browns .Sienna );
56+ colors .put (59 , PenColors .Grays . DarkSlateGray );
5557 Tortoise .setPenColor (colors .get (branchLength ));
5658 }
5759}
0 commit comments