Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Demonstrates the BookSameName and TextBookSameName classes.
- */
- class SameNameDemo
- {
- private static void printOut(BookSameName[] bs) //method that prints an array of books.
- {
- for (BookSameName b: bs)
- {
- b.put(); //uses the put() method from both classes
- }
- }
- public static void main(String[] args)
- {
- BookSameName[] bs = { //array of 2 Books.
- new BookSameName("Will","Hamlet"),
- new BookSameName("Arnie", "I'll Be Back")
- };
- printOut(bs); //using the method that prints an array of books
- TextBookSameName[] ts ={ //array of 2 TextBooks
- new TextBookSameName("Meg","Java",2),
- new TextBookSameName("Jilly", "Java", 3)
- };
- printOut(ts); // same printOut as for Books
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement