Lab 2
1 Lab Objectives
Re-iterate when to create each of interfaces and abstract classes when designing class hierarchies.
2 Design and Implementation Problem
This week, we take a fresh look at the ITunes example from last week. Now your software needs to manage three kinds of items, each of which has a title and a duration: songs, podcast episodes, and audio books. Despite these similarities, these items also have some differences:
Songs and Podcast episodes are part of a larger collection. Songs are part of albums, which have an artist and a number of tracks. Podcast episodes are part of podcasts, which have an author and a frequency at which to check for new episodes (daily, weekly, or unchecked).
Songs and Podcasts are categorizable items; each belongs to a genre, such as news, entertainment, or business for podcasts and rock or country for songs. Users may enter exactly one genre classification per item.
Albums and Audio Books are published works. Each has a publisher and a year of release.
Your task is to design a class hierarchy for Media Items that has all of the above features. You’ll do this with a combination of interfaces and abstract classes.
Create an interface for media items. Create classes for each of songs, podcast eipsodes, and audio books that implement this interface.
Create classes for albums and podcasts, with the fields as described above.
Introduce the notion of an item in a collection (ie, songs and podcasts) into your class hierarchy. What in your code indicates that songs and podcasts are in this category? How did you require that they each item in a collection contains a way to access the information about that collection?
Similarly, add a notion of categorizable to your class hierarchy and apply it to songs and podcasts. You should be able to answer the same questions as when you added collections.
Now add a notion of published for Albums and Audio Books, answering the same questions about required components.
Develop your Examples class as you go to check that you understand the definitions you are creating.
3 What to Turn in
Submit all .java files that you produced for this assignment to the Lab1 area via Turnin. If you don’t have a Turnin account or don’t find CS2102 under your available courses, ask your lab staff to create one for you.