Week12: Exceptions

MONDAY:

Today we added the ability of eating food to our Fish class.  This was an organizational decision that we spent some time discussing.  Then we replace our console based textual output to a more graphical windowed display using processing.  Here’s a link to the core.jar file that you can also download freely from processing.org.  And our update FishTank, Food, and Fish classes:

WEDENSDAY:

We reviewed the most commonly missed exam questions on this day.

FRIDAY:

Today we tied up two loose ends (the final commonly missed exam question, and the Fish Tank Simulation).  In addition to adding an image for our fish, we saw examples of using inheritance to reduce two different kinds of redundancy in this code: 1) using different types of objects in common ways with the same code rather than redundant code, and 2) including code that is repeated across many classes into a single class that is shared with every class that extends it.  Then finally we started to unravel the problem and approach of Exception Handling in Java.  This is something that we’ll continue to discuss next week as we get into FileIO.

HERE’S the complete FishTank simulation project with the core.jar and FISH.png files.

And here’s the problematic code that may throw many different kinds of extensions.  If you can find these different kinds of exceptions before class on Monday, that will be helpful preparation for our discussion and demonstration of try-catch-finally blocks: