Testing the Container Icon Tree part
Select
to test the part. Select the Ace and King of each suit from the deck and then select
Discard selected from the
Deck menu. A suit icon should appear in the discard deck for each suit. There should be a small push button to the left of each suit icon which can be used to expand and collapse the tree.
Expand a tree. You should see all the cards of the selected suit that are currently in the discard deck. Each card will be below and to the right of the icon that was expanded. Collapse the tree. The cards that were shown earlier should no longer be visible.
Expand a tree again. With the tree still expanded, discard another card from the deck. Notice that all expanded trees were collapsed. This occurs because our implementation creates a new ordered collection for the suit root nodes whenever the discard deck's contents change.
An alternate implementation would be to create the ordered collection once, when the application is started with all four suits as items regardless of the contents of the discard deck. The suits script would then update the hasChildren attribute for each suit whenever the contents of the discard deck changes. This implementation, by keeping the same suit items throughout, would allow the container to remember when its items were expanded and keep them expanded after its items are refreshed. If you wish, you can implement this solution for extra practice.
Last modified date: 06/11/2018