Tuesday, October 26, 2010

Not So Good Solutions

The solutions Shamik and Humayun provided below, while functional, are not really how you should solve these problems. Specifically, you should not use instanceof. You should use inheritance instead. I'll explain in class. I'm going to have to give them a B- for these solutions.

The simple rule is: never use instanceof. There are some rare occasions when its useful.

No comments: