The AND simulator in VB.NET
Answers are for parents and teachers.
1
Trace the correct code from the start state for the clicks A, A, B. Give the state after each click.
After A: On Off, unlit. After A: Off Off, unlit. After B: Off On, unlit.
2
Trace the clicks B, A, B, B. Is the lamp lit at the end?
After the clicks: Off On, On On, On Off, On On. The final state is On On and the lamp is lit.
3
Trace the clicks A, B, A, A, B and give the final state.
After the clicks: On Off, On On, Off On, On On, On Off. The final state is On Off and the lamp is unlit.
4
Fill the gaps in SwitchB_Click: If SwitchB.Text = "Off" Then SwitchB.Text = "On" : If ____ Then ShowLamp(True) : Else SwitchB.Text = ____ : ShowLamp(____).
The first gap is SwitchA.Text = "On"; the second is "Off"; the third is False.
5
What is the smallest number of clicks that lights the lamp from the start state? Name two ways.
Two clicks: A then B, or B then A.