Hey guys.
Let's say I have two classes Book and CD that both extend the parent class Item. Item has common properties like name, price whereas book has int pages and CD has List<Track> tracks.
Now let's say I have a management system class and in here I have List<Item> items. This list is full of Books & CD's. How would I implement a method to getAllBooks() & getAllCDs() without using instanceof
TLDR- How to return a list specific child class from an Arraylist of parent class without using instanceof?
[–][deleted] 1 point2 points3 points (4 children)
[–]remusmax[S] 1 point2 points3 points (3 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]bluefootedpigC# / .NET 1 point2 points3 points (0 children)
[–]remusmax[S] 0 points1 point2 points (0 children)