Solved

[c++]  event driven programming

Posted on 2007-11-26
5
883 Views
Last Modified: 2011-10-03
I don't exactly know what this term means,


for instance, to write a program to simulate a mouse trying to go through a maze, and I treat the mouse with sensors,  how do I write the thing that keeps reading the data coming in from it's sensors and then decide on what to do next?

0
Comment
Question by:Troudeloup
5 Comments
 
LVL 1

Assisted Solution

by:yyyc186
yyyc186 earned 150 total points
ID: 20354563
Please define what you mean by "simulate a mouse trying to go through a maze" and "sensors".

Is this a homework problem?
0
 
LVL 4

Assisted Solution

by:Ichijo
Ichijo earned 100 total points
ID: 20354683
An example of an event-driven maze traversal program for a sensor-equipped mouse would be, instead of telling the mouse to move one step and then check to see if it has bumped into something, you just tell it to walk straight until told otherwise. Then you have an event handler procedure that will run automatically whenever a collision event occurs (when the mouse bumps into a wall). Your event handler might tell the mouse to change direction, or take some other action of your choice.
0
 
LVL 1

Assisted Solution

by:yyyc186
yyyc186 earned 150 total points
ID: 20354727
You also need to check for possible turns reading those "sensors" or you will never get out of the maze if there is a turn not at a wall.

----------| |----------
|                             |
-------------------------

Once you get into something that looks like the above, you cannot get out.
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 100 total points
ID: 20355417
You basically nee to implement the concept of a "state machine" (see e.g. http://en.wikipedia.org/wiki/State_machine), that is software that given to a current state (e.g. "moving right") reacts to a signal ("wall approaching") with a predefined reaction (e.g. "turning left"). How that is done in detail is up to the constraints you are facing, thus it is hard to give any more specific advise.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 150 total points
ID: 20356348
>> event driven programming
>> I don't exactly know what this term means,

It's a programming technique that defines the flow of the program based on user actions or other (usually external) events (like messages, etc.). For example, if the user clicks a mouse, then some routine is executed to handle the mouse click event.

Or in other words, there's no execution from beginning to end, like a classic program would do ... instead the program is just sitting there, waiting for events, and whenever an event occurs, the proper action is taken to handle that event.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question