Assignment 6

Remember that important terms are bolded at least once.

Assignment 6A

Create a list of 5 flowers. Add a picnic table to the world as well.  Create an event that uses When mouse clicked to perform a method you have also created named PlaceOnTable.  The PlaceOnTable method should have a parameter named WhichFlower.  Use the parameter in PlaceOnTable to get the flowers to move to the top of the picnic table.  The main method should display 3-D text that says “Click on each flower to play  or whatever to communicate to the user what to do.  The PlaceOnTable is probably best placed in the Click event.  You can optionally place it in the my first method if that method is called from the click event.  Depends on how you set it up.  It MUST have a list, however.

 

NOTES to remember

(In real programming languages you would have to fill this list with a loop, an interation structure – similar to the description of an array in chapter 10 of the text. However, when using lists in ALICE, an easy NewItem button is provided so you just have to click from the dropdown list of all the object in your world to fill the list when you create the list.  With each new item there is a position number for each element/item referred to as an index.  When the list/array was created, a set of memory locations beginning with, let’s say, 15000.  The first flower occupies position 0 or the first position in the list/array.  The next flower would be stored continguously-right next to in memory- the first one.  Let’s assume that a particular flower object needs 10,000 bytes of storage in memory-it is graphical after all.  The starting address for the item listed first in the list –remember the first one in position 0- so the 2nd item in a list/array  would be stored at memory address –location -15,000+10,000 inclusive of the 15,000 or memory location/address 24,999).

 

In ALICE there are built in structures- ‘for all in order and ‘for all together’ to manipulate the

index.  The index IS being changed, but the programmer does not see the built-in code which is one of the advantages of object oriented programming since all of ALICE projects are made up of objects, properties and methods.

Assignment 6B

Notes to remember first

 

Although lists and arrays have some major differences in ALICE, they do not have these in programming languages.  There are static (unchanging) and dynamic (changes size) arrays, however.  That said, indexes are used in arrays and are required because of the varying address locations discussed above.  The index is used to indicate which of the elements of the array/list is being referenced.  The computer uses that value and the size of each element to calculate the address/location of the item in the list is being referenced in the command. (See simple example above in the programming section).

 

Questions

1.    What is the value of the index position for the first element in an array/list __________

 

2.    The project you created in Part A required a mous click in order to execute.  Clicking a mouse is referred to as a(n)_________________

 

3.    How many items are stored in the list/array of flowers?____________

 

4.    Create a class diagram for the class flowerpot that you used in the project.  You do not need to include all of the properties and methods…3 of each will do.

 

5.    Would all flowerpots have these same attributes and methods?  ________________

 

6.    Consider question 5 and explain WHY ______________________________

 

7.    Define a list/array- remember in a real language there is no significant difference.

 

8.    Create a Use Case for the small application you wrote in Assignment 6A.

 

9.    What is the advantage to breaking a program into many “independent” methods?

 

10.Some programming languages allow the use of a concept named ‘polymorphism’.  Use the following source to learn what it is.  It is also a good source for some other explanations. http://home.cogeco.ca/~ve3ll/jatutor5.htm  It uses JAVA as an example.

 

11.  Give an example NOT in the material assigned or research of polymorphism.