Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This is called TextBookSameName as it is showing the use of using methods
- * with the same name on inherited methods. The only difference between
- * this and TextBook is that putTextBook() is called put() here and instead
- * of just calling the method putBook(), you call super.put()
- */
- class TextBookSameName extends BookSameName
- {
- private int level; // in addition to author, title
- TextBookSameName(String a0, String t0, int l0)
- {
- super(a0,t0); // re-use parent constructor in Book
- level = l0;
- }
- void put() //print method, same name as in Book, this takes precendence
- {
- super.put(); // note the use of super here, this is to invoke the inherited put()
- System.out.println(" Level " + level);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement