House Lights Example for UML Diagrams

This assumes you've used EA to create an empty project.

  1. Add a package, right click on the package and select Add Diagram..., then UML Structural, and finally UML Structural::Class
  2. Create a UML class diagram to match the following. Capture associations, attributes, methods, generalization, and multiplicities.

    House lights come in two forms: auto-dimming and standard. Every light is associated with exactly one toggle switch, and every toggle switch is associated with exactly one light. Toggle switches have the operation toggle. Lights have the operations turn_on, turn_off, and toggle. All lights also have a boolean is_on attribute. Auto-dimming lights also have an attribute seconds_to_off and a method tick. There is a master switch for the whole house with two operations: enable and all_off. All lights are associated with this switch.

  3. Add a state diagrams for the two types of lights. Standard lights respond to the switch's toggle operation by turning on if they were off and off if they were on.
    Auto-dimming lights respond to the toggle operation by turning on if they were off. However, if they are on, respond to a toggle by turning off after 30 seconds. If the toggle switch is not pressed at all, the light turns off after 600 seconds (10 minutes). The initial state should be off for both, and both respond to the turn_off command from the master switch by going off immediately.
    Note: add a state diagram by right clicking on the class and selecting New Child Diagram and State Diagram. Set the name to include the class name and the word "state".
  4. A solution is available: house-lights-solution.qea