Candy App Sample


Purpose

1) Simulate a trick-or-treater going to houses and getting candy in their bag
Some characters are prohibitied from eating certain candies:

  • Minnie is allergic to nuts
  • Goofy has braces
  • Daffy has braces AND is allergic to nuts

Those allergic to nuts cannot eat Snickers, Peanut MMs or Reese's Cups
Those with braces cannot eat ButterFinger or Airheads

2) To enable testing, simulate a parent going through the bag, checking each piece of candy to see if is "ok to eat"

Functionality

Trick-or-Treating:

Click on the name drop down to begin trick-or-treating
When "Trick of Treat" is clicked, a random piece of candy is selected from the list
if the character can eat it, that candy is added the "bag" (a list), the entire list is displayed and the number of candies is updated
otherwise, a message is displayed saying they can't eat that

Checking Candy:

When Check Candy Bag is clicked, the check candy screen is initialized with the trick or treater's name and the first piece of candy
The Previous and Next buttons implement the "scrolling pattern" --

  • clicking "next" causes the candy at the next index to be displayed (unless the index is already at the end)
  • clicking "prev" causes the candy at the previous index to be displayed (unless the index is already at the first of the list)

@Copy2024 mBish