Goal: Our Goal is to build an App that will randomly assign a chore to a family member/friend.

Phase 1

1. Add a button with the the text “Make Chore List” or something similar.

2. Add a Textbox.

A) You should make the textbox MultiLine because we will use the textbox to display the chores for several people.

3. Make two lists and attach them to two unique variables.

A) A list of family member names

B) A list of chores.

C) Be sure that your variables are named with useful names.

4. Use a when.Click block to give functionality to your “Make Chore List” button.

A) We want the button to make a list, but first we need a variable to hold the string of characters associated with the chore assignment. I called mine ChoreListString. Make a variable like the one shown in this image.

B) We will use the following blocks set our variable with a random chore assignment.

C) Note that our set.Text block displays our text in the textbox that we labeled ChoreListDisplay.

5. Test out your app

Phase 2

Improvement: The way we have it coded, we have to keep clicking the button to get a chore for everyone. It would be ideal if we could click the button once and output everyone’s name and their chore.

1. The idea is this. We have a string that we are building. Let's call it our "ChoreListString"

We say something like:

While not done:

join the contents of the string with a new work assignment.

Store it back in the string.

In code that looks like:

While Not Done

***Notice the string "\n" that we add between each assignment. Can you figure out what it is doing?

Explain to your neighbor why the ChoreListString occurs TWICE in the above statement.

2. But how do we do this setting of the ChoreListSring repeatedly? We want to do something once for each item in the WorkerList. This need is so common, they have a special control command just for this. The for each Item in list repeats the statements once for each item in the list. This is called a for loop.


3. Notice what things go before the for loop and which go after. Don't forget to set the ChoreListDisplay after you finished adding to the ChoreListString.SetChoreListDisplay.PNG

4. Test your App

Phase 3

Improvement: Because all decisions are made randomly, we have some people getting several chores and others getting none.

1. Rather than randomly picking a worker, we can use the variable item (supplied by the for each loop) to look at each worker in turn.


2. Test out your app. This is so close! How could you improve it more? You might want to set ChoreListString back to " " each time you click the ChoreListButton.

Phase 4

Improvement: To avoid multiple people getting the same chore, we need a new plan. We can't randomly pick a chore. Our for each loop is progressing regularly through the WorkerList. But can we progress regularly through the ChoreList and still make different assignments?

Here is one way to do that: we will need to pick a random starting point for the chore list. When the user presses the ChoreListButton a long time, make assignments so that there are no duplicate assignments.

Consider the following lists:


Here is the idea. You still step through the workers one at a time. So we assign to the workers in the following order:

Sue Please Do Do
Linda Please Do
Andrea Please Do
Vicki Please Do
Fred Please Do
Christina Please Do

We randomly pick a starting point in the ChoreList.

If we start at item 3 in the ChoreList, our output will look something like:

Sue Please Do Do Dishes
Linda Please Do Make Dinner
Andrea Please Do Wash Counters
Vicki Please Do Sweep Floor
Fred Please Do Set Table
Christina Please Do Clear Table

The workers always appear in the same order, as we just stepped through the list.

The chores ALSO appear in the same CYCLIC order. We just change where we start in the chore list.

Try to do this on your own. If you get stuck, look here. If you are really stuck, look here.

Useful Terminology
For Loop --