Exercises

   

Java™ 2 Primer Plus
By Steven Haines, Steve Potts

Table of Contents
Chapter 9.  Exception Handling


1:

In the previous chapter you created a set of animals that followed an inheritance hierarchy. In this chapter, I want you to modify the animals created in the previous chapter and add a new custom exception called too tired. Because each animal implements a play method, you should add a too tired exception to the play method's exception list. In each animal that plays, try to maintain their energy level. Upon each invocation of the play method, decrement the energy level. When the energy level reaches 0, throw a too tired exception. Modify your animal trainer source code to generate a too tired exception in one or more of your animals.


       
    Top
     



    Java 2 Primer Plus
    Java 2 Primer Plus
    ISBN: 0672324156
    EAN: 2147483647
    Year: 2001
    Pages: 332

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net