Quote:
simulate the operation of an elevator
An elevator is an automata, which mean that it operate with events.
So it is all a matter of logic, and all fit in 1 question: "What happens if ?"
To know if you need a variable, answer this question: "Does it operate differently if ?"
- totalRiders: Does it operate differently depending on the number of riders ?
- loadingRiders, unloadingRiders: Does it operate differently for loading riders and for unloading riders ?
- loadingRiders, unloadingRiders: Does it operate differently if no rider load or unload.
Quote:
1) Basically, at the start, the elevator is situated at a given floor. Its first action is to load on some passengers.
Are you sure about the first action ? What if elevator is on floor 4 and you call it from floor 1.
Quote:
3) At the destination floor it performs two actions:
- offloads a certain amount of riders (not necessarily all of them)
- onload a certain number of people (but do not overload the elevator) // Would these two actions also be loops as well for loading and unloading riders?
Do you really think the elevator is counting the passengers ?
Quote:
And if some of you are going to be rude, just don't answer my questions.
Sometimes, having someone being a little rude to you, is the best way to make you crank your brain, and finally being good to you.
Albert Einstein wrote:
Everything should be made as simple as possible, but no simpler.