please help me with this!

hi im a student in college and stuck with a programming teacher who really doesn't know how to teach. I need to make a 4 state machine (it doesn't really do anything beyond change states) but he didn't give us an example to work from. if someone could show me a simple one and walk me through it I would really appreciate it
Last edited on

hi im a student in college and stuck with a programming teacher who really doesn't know how to teach

Oh another one very clever student unjustly oppressed by very stupid teacher?


but he didn't give us an example to work from

What is the problem with working from scratch? Supposed program is so trivial that any example would be almost complete solution.

Do not you know how to start the program in C++? Write main function, add some input, some output...

When you'll have some specific question - welcome to ask.
Last edited on
Thanks for the help... NOT!!!!! This is my first c++ class jerk and I don't like stumbling around in the dark! If you ever feel like sharing from your obviously great knowledge (insert sarcastic quotation marks and tone here) feel free to comment again.
Sorry...I just didn't appreciate his comment. I did look up examples but they didn't really make sense....I do better when I have a whole program to work from not just snippets
My personal experience is that even the nicest programmers can come off as being arrogant to beginners. Usually, this is because they're being extremely realistic, which is a developed personality attribute that is rewarded in a programming environment.

You mentioned that this is your first programming class. What knowledge do you have under your belt? Are there any other specific requirements to the four-state machine assignment? We'll be able to help you more effectively if we have an idea of where you are at.
Last edited on
I have a little bit of java and the only requirement that he gave was it had to switch between 4 states and one of them is a default exit state.. it really just switches between states.....
If you want to be a programmer, you need to be able to take 1/2 ass instructions and be able to write code that performs the task, then be able to explain what it does to others. If you think everyone who gives you an assignment is going to tell you exactly how to do it, your diluding yourself.

Welcome to college, The real test is called a job.

Just a thought. If the instructions are too hard, maybe you should take the beginner class.

I"m sure your book has examples but Google does too, Try reading:
http://www.drdobbs.com/cpp/state-machine-design-in-c/184401236

If you want help here, post your code with your questions. Otherwise your not going to get someone to do homework for you. GL
Last edited on
There was no beginner class this was the only one offered. I know he's not going to tell us how to do it, I don't expect him to. I would just like more information, an example of something that I have never seen before. I did just fine in my java class, the guy would walk us through the example program and then we would write a similar (but change the function and appearance) code and demonstrate it at the end of class. I understood it when we did that. This guy quotes from the book gives us technical definitions and expects to solve it from there. I'm just a little confused is all.
You can find a pretty good example of a C++ state machine here:

http://bit.ly/1aI8dyn

I'd recommend checking out how to enum a states variable and making a case structure around that.

Ok fine:

if you make a states variable:
enum states;

you can have a case structure:

case(states)

and then have your states in each case block. When you receive an input that changes the state, you can change the state in the case blocks, and the state machine will change states about as quickly as I know how to make happen.
Last edited on
Topic archived. No new replies allowed.