Mini-Lab: Class Implementation

Creating Items to go in a Collection


This mini-lab may be done individually or in pairs. It is okay to get help from the TAs and/or the instructor if you get stuck, but you (and your partner, if you have one) should try to do it on your own first.

Tip: You should get into the habit of making backup copies of your work.


A common pattern in computer programming is to have a collection of items that one has to traverse (step through) in order to print information about the items, search for a particular item, do a calculation based on all the items, etc.

The table below shows a number of different contexts for such collections, but all of them have a few characteristics in common. The items in each of these collections include:

For example, a program keeping track of runners in a marathon or swimmers in a swim meet might include a race number, athlete name, team name, and finish time. A program tracking grocery store inventory might keep track of item codes, descriptions, department (produce, meat, deli, etc), and price. Software for an art gallery might include an ID number for each art work on sale, a title or desciption, the name of the artist, and price. Environmental researchers might keep track of the number of members of various plant or animal species in a geographic location by recording each species name, whether it is endangered or in some other category, and how many individuals (or maybe mating pairs) are in the location being studied.

ContextItem TypeIDName/Description CategoryNumeric Comparator
Athletic EventAthlete Race NumberAthlete Name Team or Country Finish time, number of goals, etc.
CollectionCoin/Stamp IDDescription CountryValue
MenuMenu Items NameDescription Appetizer, Dessert, etc.Price (or Calories)
StoreInventory Items Item CodeName DepartmentPrice
GardenPlants Item CodePlant Name CategoryNumber of plants (or rows or acres) to plant
Ecol. ResearchSpecies Latin NameCommon Name Endangered, Critical, etc.# Individuals
GalleryPieces of Art Item CodeTitle/DescriptionArtistPrice
LibraryBooks, Songs, Albums IDName Author, ArtistPrice (or Length)
Cookie SalesBoxes of Cookies AddressFamily Type of CookieNumber of boxes
Faculty ListFaculty IDName DepartmentYears of Service

Mini-Lab Exercises

You do not need to submit this mini-lab. You will be adding to it in a follow-up mini-lab.