Campbell Ritchie wrote:This current method cannot handle input validation, so it either needs a guarantee that input will be in the correct format or to throw an exception.
I think it is only a matter of time before a user mistakenly enters something wrong.
Junilu Lacar wrote:. . . There’s no guarantee that any user will do what your program instructions tell them to do. . . . .
Campbell Ritchie wrote:Surely it is the input method's responsibilty to validate it? And the only way it can know about that is by having an exception thrown at it.
S Fox wrote:so i suggest an array of button objects, one per floor.
Ok, sorry for misunderstanding you.
S Fox wrote:i never suggested to have 100 buttons lol
so i suggest an array of button objects, one per floor.
Piet Souris wrote:This topic has gone out of hand. It was just an exercise in java, about an elevator that could handle commands like 'U3' and 'D2'. Got little to do with reality. It is therefore completely up to the programmer what to do with it. Throw an exception when a typo is made? Or handle it with grace like Junilu proposed? Up to the programmer, who is wrtiting this code to gain experience and knowledge and is its only user.