Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. /*
  2.  * Demonstrates the BookSameName and TextBookSameName classes.
  3.  */
  4. class SameNameDemo
  5. {
  6.     private static void printOut(BookSameName[] bs)                         //method that prints an array of books.
  7.     {
  8.         for (BookSameName b: bs)
  9.         {
  10.             b.put();                                    //uses the put() method from both classes
  11.         }
  12.     }
  13.                
  14.     public static void main(String[] args)
  15.     {  
  16.         BookSameName[] bs = {                                   //array of 2 Books.
  17.                 new BookSameName("Will","Hamlet"),
  18.                 new BookSameName("Arnie", "I'll Be Back")
  19.             };
  20.         printOut(bs);                                       //using the method that prints an array of books
  21.      
  22.         TextBookSameName[] ts ={                                //array of 2 TextBooks
  23.                 new TextBookSameName("Meg","Java",2),
  24.                 new TextBookSameName("Jilly", "Java", 3)
  25.             };
  26.         printOut(ts);                                           // same printOut as for Books      
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement