Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. /*
  2.  * This is called TextBookSameName as it is showing the use of using methods
  3.  * with the same name on inherited methods. The only difference between
  4.  * this and TextBook is that putTextBook() is called put() here and instead
  5.  * of just calling the method putBook(), you call super.put()
  6.  */
  7. class TextBookSameName extends BookSameName
  8. {
  9.     private int level;                                      // in addition to author, title
  10.    
  11.     TextBookSameName(String a0, String t0, int l0)
  12.     {
  13.         super(a0,t0);                                       // re-use parent constructor in Book
  14.         level = l0;
  15.     }
  16.    
  17.     void put()                                          //print method, same name as in Book, this takes precendence
  18.     {
  19.         super.put();                                        // note the use of super here, this is to invoke the inherited put()
  20.         System.out.println("     Level " + level);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement