| | |
Real-time simulation problem
![]() |
Hi everybody! I recently wrote a little simulation program, that simulates a real-time elevator system with 3 elevators. Since the code is around 530 lines I presume it is not a good idea to paste it here. There is some number of minor flaws of logical type and I would be very thankful on any ideas or corrections.
Since I don't posses any web space and I believe that corrections will be (probably) move obvious on a personal machine I can send the code to the email of anybody who's interested. I guarantee that no harmful programs will come with the email, in case somebody may think so.
If somebody is interested please answer to this post or send me a personal message with your email. If you have a better proposition than the email option that I can think of at the moment - please, of course, share it with me
Thanks to all in advance!
Since I don't posses any web space and I believe that corrections will be (probably) move obvious on a personal machine I can send the code to the email of anybody who's interested. I guarantee that no harmful programs will come with the email, in case somebody may think so.
If somebody is interested please answer to this post or send me a personal message with your email. If you have a better proposition than the email option that I can think of at the moment - please, of course, share it with me
Thanks to all in advance!
liblifts.h is the dirty worker in this case so this is the place. I presume that the Elevator class is the primary and probably almost only source of errors. The open_doors() function and the move() function are probably most critical. If I must be sincere - I don't have an exact idea what's wrong .. if I did have one I would try to correct the code myself.
I bet you know what I'm gonna say don't you.
Let me guess, you wrote the whole program in one go, and then hit compile and execute and expected it to work?
My advice would be to test each function or in your case, each method, separately and make sure it's doing what it is supposed to. Once you've gone through each method systematically you should be able to find out what's going wrong and where.
It's the only way.
Another thing, I noticed, it appears you're not freeing up your memory.
Where's your use of delete[].
And you really need to work on your indentation. It's horrendous. I also hate the use of try catch statements in c++, but that's just me.
Let me guess, you wrote the whole program in one go, and then hit compile and execute and expected it to work?
My advice would be to test each function or in your case, each method, separately and make sure it's doing what it is supposed to. Once you've gone through each method systematically you should be able to find out what's going wrong and where.
It's the only way.
Another thing, I noticed, it appears you're not freeing up your memory.
Where's your use of delete[].
And you really need to work on your indentation. It's horrendous. I also hate the use of try catch statements in c++, but that's just me.
*Voted best profile in the world*
Generally you're right about the testing. I can't think of a way, though, to check every function, especially when one function often uses the other from the same class and executable code is produced only when all the used functions are written down. Once the whole picture is clear I can start tracking down the problems.
As for delete[] - this belongs to the last actions I have to do. My primary concern at the moment is that the code starts running as it is supposed to do :-) Optimization belongs to the last stage before giving up the ready code and will be done, I can assure you.
As for delete[] - this belongs to the last actions I have to do. My primary concern at the moment is that the code starts running as it is supposed to do :-) Optimization belongs to the last stage before giving up the ready code and will be done, I can assure you.
freemind: You know that you're not supposed to put function bodies or variable definitions in a header, right? (Well, now you do.)
I may actually help more later on, but there are many things that make this code difficult to look at and understand. So I'm taking my time.
I may actually help more later on, but there are many things that make this code difficult to look at and understand. So I'm taking my time.
“The essential notion of a socialist society is force.”
— Milton Friedman
— Milton Friedman
![]() |
Other Threads in the C++ Forum
- Previous Thread: Dynamic Array and Pointer
- Next Thread: I/O question. using vc++ read char by char
Views: 2428 | Replies: 13
| Thread Tools | Search this Thread |
Tag cloud for C++
6 algorithm array arrays assignment beginner binary browser c++ c++borland c/c++ calculator char class classes code compile compiler constructor conversion convert count delete dll dynamic encryption error file files filestream forms fstream function functions game givemetehcodez graph graphics gui homework iamthwee input int lazy link linker list loop looping loops math matrix member memory newbie number object objects opengl operator output parameter pointer pointers problem program programming project python random read reading recursion recursive reference return server sort spoonfeeding string strings struct student studio template templates text time tree undefined variable vc++ vector video visual win32 window windows winsock wxwidgets






