CJCoding With Joseph

Toggling Encapsulated State

The LightSwitch class has a private bool field isOn that starts false. Add a method Toggle() that flips it and a read-only property IsOn that returns its value. Do NOT write a Main method.

After one call to Toggle() the program prints:
True

Expected Output:

True
Topics:
Encapsulation
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.