|
|
|
|
|
by ntumlin
4695 days ago
|
|
Just looking at elevator.cpp briefly, it seems like some comments are unnecessary, e.g., stating that the constructor is the constructor. Also, I was confused by the switch statement that took a boolean and had a case for true and false. Why didn't you use an if statement? |
|
You know, it never occurred to me to do that, but I think there may be times when that would be a clearer idiom than an if statement (as long as you put "default:" immediately after "case true:"). I always feel like the order of clauses in an if-else gives a sense of privilege to whichever case is handled first, but there's less of that sense with a switch statement.
In particular, I think it might be a good alternative to conditionals on non-boolean arguments. For example, instead of:
You could use: