1 Lab Objectives
2 Choose and Setup your Java environment
3 Design and Implementation Problem
4 What to Turn in

Lab 1 – Advanced

1 Lab Objectives

  1. Get your Java environment configured with the check-expect testing library

  2. Confirm or refresh your Java design skills.

Some aspects of the 1101/1102 style of writing Java differ from how you probably learned to write Java before (e.g., creating new objects instead of mutating existing ones). We know that. We start this way because there are a lot of design subtleties to using mutation safely. We will cover these in detail after your classmates who are new to Java get up to speed.

2 Choose and Setup your Java environment

If you already have Java experience, we recommend you use Eclipse (unless it annoys you and you prefer a simpler environment). You can find either Eclipse or DrJava by typing in the name in the search box under the programs menu on the lab machines.

If you are using your own laptop, download and install whichever tool you wish to use. See the separate instructions on configuring your environment to use the testing library.

3 Design and Implementation Problem

Assume you are creating a class hierarchy for a media manager 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:

Design a class hierarchy for MediaItem that has all of the features and data described here. You may put all the definitions in a single file or one definition per file, as you prefer. Your design should satisfy the following criteria (include a comment at the end identifying the aspect of your design that satisfies each one):

  1. Concepts of collection, published and categorizable are explicit in the code for your class hierarchy.

  2. Frequency checks are only supported on the pre-defined intervals.

  3. If one added a new kind of media with some combination of the collection, published and categorizable, Java would help check that all relevant methods and data were included for the new media type.

Once you have your definitions, make some examples of data in an Examples class and make sure that you are able to load that class (to check that you have the tester infraastructure configured correctly). Add a simple test case that checks the value of one of your examples to confirm that you have tests working.

4 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.