[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

[c++]  event driven programming

Posted on 2007-11-26
5
Medium Priority
?
917 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 600 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 400 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 600 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 400 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 600 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

834 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