1Looping Through Lists2/13/20082Opening Discussion■Let's look at some solutions to the interclass problem.3A Little More Lists■Last class we created two lists and went through them in different ways.The list of objects to tag we went through with the doAllTogether operation.The list of strings we went through using the index of a for loop.■We didn't use the functionality that Alice provides for adding to lists or removing from them. Let's write some code now that will do that. We will cheat and throw in a mouse event as well.■There are some challenges with lists of objects in Alice. I view these as a limitation on the Alice type system.4Animating Lists/Arrays■If you tried to animate your list by giving the objects on your list a walk method you probably found there was a problem. Alice won't let you say item_from_list.walk. This is because item_from_list could be any object in the Alice world and not all objects in Alice have a walk method.■How then do we animate objects using a list/array in Alice? The partNamed method lets us pull of sub-parts of an object to move for the animation.■This is more tedious than I would like, but it follows the strong static typing of Java and the lack of subtyping in Alice.5Random Numbers■For your project you might want some things to happen a bit differently every time it runs. For this you need random numbers.■The world has two methods to return pseudo-random boolean and double values. (For our purposes a double is just a number.)6Minute Essay■Is there any part of your project where you might use random numbers? If so, when?■You can also let me know if you have any questions about lists or arrays.■Quiz #3 will be at the beginning of next class.■Interclass Problem – Do problem 5.5 of
View Full Document