Changes between Version 1 and Version 2 of ControlSystems/SoftwareTeam/Training/GettingStarted/StateMachines1


Ignore:
Timestamp:
Nov 6, 2019, 11:50:07 AM (6 years ago)
Author:
David Albert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/Training/GettingStarted/StateMachines1

    v1 v2  
    3434}}}
    3535
    36 This program introduces a new type of variable called an enumeration ('''enum''').  An enum is a variable that can hold one of the values you specify when you declare it.  For example: {{{ enum Color { RED, GREEN, BLUE }; }}}  In this example, we've enumerated the states the robot can be in: starting, driving forward, turning, and stopped.
     36This program introduces a new type of variable called an enumeration ('''enum''').  An enum is a variable that can hold one of the values you specify when you declare it.  For example:
     37 {{{ enum Color { RED, GREEN, BLUE }; }}} 
     38In this example, we've enumerated the states the robot can be in: starting, driving forward, turning, and stopped.
    3739
    3840The program also introduces the '''switch''' statement which is another type of conditional like ''if ,else if, else''.  With a switch statement, the condition is the value of a variable; execution jumps to the ''case'' that matches the variable's value and proceeds forward from there until a ''break'' statement is encountered which exits the switch block.  If there is no case statement matching the variable's value, the '''default''' case is executed.