Several common gestures consist of a repetitive, back-and-forth movement. Consider the following examples of this type of gesture:
- Nodding (yes or I'm listening)
- Shaking one's head (no or dismay)
- Waving (a greeting)
- Shaking hands (a greeting)
- Shaking one's fist (a threat or a protest)
- Wagging a finger (scolding)
- Wiggling a finger or fingers (beckoning)
- Tapping one's foot against the ground (impatience)
- Tapping four fingers against a table (impatience)
- Tapping two fingers against a table (Thanks for the green tea)
- Pacing (anxiety)
- Jumping up and down (excitement, joy)
To help us recognize such gestures, let's write a class, BackAndForthGesture, which keeps track of the number of times that a value (such as an x coordinate or y coordinate) has oscillated between a low threshold and a high threshold. A certain number of...