Quantcast
Channel: ZebraZapps » learning solutions
Viewing all articles
Browse latest Browse all 10

ZebraZapps Challenge #6

$
0
0

OK, Zebra Challengers, this week we’re moving forward into implementing some logic into your applications.  I’ve built a two-part application for you to try to recreate.  As always, I highly recommend a “divide and conquer” approach to solving this exercise.

The application creates two simulations:  one of the workings of a typical light switch; the other, the workings of a three-way switch (i.e., wiring situation where two light switches are used to control a single fixture).

Part 1

The first is visible by default when the application is launched (or if you click the “Two-Way Switch” button).  When the wall switch is flipped on, the bulb glows.  When it is switched off, the bulb stops glowing.  Most of the images are provided for you in the Zip file.  You’ll need to draw the line that shows the connection made inside the switch.

Hint:  explore the Graphic Button features on a Checkbox object.

Part 2 

The second part  gets a little more challenging. – as the decision to have the light glow is based on two inputs.  If both switches are in the ON position the light will glow.  If both switches are in the OFF position the light will glow.  Otherwise the light will be off.

Hint:  you’ll want to use a Truth Table to decide whether the bulb glows or not.

A quick word about Truth Tables:

Truth tables are designed to simplify the task of making compound decisions…or decisions that are based on more than one thing.  Here’s a typical Truth Table:

The top or gray part of the table is where the decisions are made.  The properties that are inputs to the decision are wired to the table, each in its own line.  Here, the truth table is going to make a decision based on the combined settings of two check boxes.  To the right, in the gray grid area, you can see that each column of the table shows one of the possible combinations of values.  The more inputs, the bigger this grid becomes, and eventually becomes too large to be useful.  It is great though for mapping all the combinations of a reasonable number of inputs.

The lower part (or light blue) part of the table shows the values.  This area is not shown by default.  With the table selected, you need to go to the Inspector panel and choose to Show Values.  In a very simple sense, these values are the output of the decision.  In this case, the truth table will control the visibility of the oval.  To make the choice, you need to set the values in the blue row, setting the appropriate value for the values represented by each column.  In this example, the Oval will be visible when either box is checked but not both.

Study this wiring and experiment on your own.  Understanding this will make the second part of this challenge a breeze.

Here’s the file of graphics for you to use.

 

 


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images