Lab 1
1 Lab Objectives
Re-iterate when to create each of interfaces and abstract classes when designing class hierarchies.
2 Design and Implementation Problem
Imagine you're writing software to manage a package like ITunes. 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.
Develop your Examples class as you go to check that you understand the definitions you are creating.
You should organize your solution for this and all remaining labs and homeworks as a java project (each interface and class definition go into a separate file). If you are using DrJava, refer to the documentation on the project facility. The SAs can help you if you have any questions.
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 podcast episodes) into your class hierarchy. What in your code indicates that songs and podcasts are in this category? How did you require that 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.
3 What to Turn in
Submit all .java source files that you produced for this assignment to Lab 1 via Turnin (in DrJava, under Project, choose "Create Jar file from Project", and in the next window check the option that creates the .jar file from the java source files). See you next week!