22
33import java .awt .Color ;
44import java .awt .Cursor ;
5+ import java .util .Arrays ;
56import java .util .HashMap ;
7+ import java .util .List ;
68
79import org .junit .Assert ;
10+ import org .junit .Ignore ;
811import org .junit .Test ;
912import org .teachingextensions .logo .Colors ;
1013import org .teachingextensions .logo .Tortoise ;
1114
12- //
15+
1316public class DeepDive05Recursion
1417{
1518 // How to do deep dive:
@@ -22,24 +25,6 @@ public class DeepDive05Recursion
2225 // Step 5: Advance to the next method
2326 // Do not change anything except the blank (___)
2427 //
25- // collections (hashmaps and more...)
26- //Hashmap = C# Dictionary
27- // HashMap<K,V>
28- //Array = C# Array
29- // Integer [ ] = {1,2,3};
30- // Integer [ ] = new Integer [3];
31- // List = C# ArrayList
32- // List = new ArrayLIst( );
33- // concepts to cover: recursion
34- // possible recursive ideas from lisp/clojure
35- // (defn is-even? [n] (if (= n 0) (___ (is-even? (dec n)))))
36- // (defn recursive-reverse [coll] __)
37- @ Test
38- public void gettingStarted () throws Exception
39- {
40- int number = 2 ;
41- Assert .assertEquals (number , ____ );
42- }
4328 @ Test
4429 public void changeThePointer () throws Exception
4530 {
@@ -82,14 +67,39 @@ public void getColorUsingHashKey() throws Exception
8267 Assert .assertEquals (_______ , colors .get (30 ));
8368 }
8469 @ Test
70+ public void getWhatsSecond () throws Exception
71+ {
72+ //get the second item on the list
73+ List <String > messages = Arrays .asList ("Hello" , "World!" , "How" , "Are" , "You" );
74+ String result = messages .get (____ );
75+ Assert .assertEquals ("World!" , result );
76+ }
77+ @ Test
78+ public void getWhatsLast () throws Exception
79+ {
80+ //get the last item on the list
81+ List <String > messages = Arrays .asList ("Hello" , "World!" , "How" , "Are" , "You" );
82+ String result = messages .get (4 );
83+ Assert .assertEquals (___ , result );
84+ }
85+ @ Test
86+ public void whatIsLastNow () throws Exception
87+ {
88+ //get the last item on the list now
89+ List <String > messages = Arrays .asList ("Hello" , "World!" , "How" , "Are" , "You" );
90+ messages .set (4 , ___ );
91+ String result = messages .get (4 );
92+ Assert .assertEquals ("The rest of them" , result );
93+ }
94+ @ Test
8595 public void getThirdArrayItem () throws Exception
8696 {
8797 //get the third item from the right spot using the key
8898 int [] numbers = {1 , 5 , 10 , 25 };
8999 Assert .assertEquals (10 , numbers [____ ]);
90100 }
91101 @ Test
92- public void whatDoesItStartWith () throws Exception
102+ public void whatIsThird () throws Exception
93103 {
94104 //put 25 at the third position
95105 int [] numbers = {1 , 5 , 10 , ____ };
0 commit comments