Lab 6

Purpose

This lab is an introduction to arrays. It is essential that you learn how to create arrays, how to store values into arrays, and how to index into arrays. Also, you should learn how to fix basic syntax errors that are associated with arrays. Arrays are very useful; however, they also bring with them some new and nasty potential bugs. Learning to fix these problems will save you time, plus earn you many more points on exams.

Key Reading

  • 7.1-7.3
  • review 5.6

Introduction

Cougar Media

You have decided to move beyond your life at BYU Credit Union. You and a partner have decided to purchase a media store that otherwise would go out of business, "Cougar Media." Generally your partner will run the business, and you will take care of the technical aspects. Your first task will be to catalog all of the inventory still left in stock.

Your store will sell CDs and books. Much of the information for these different types of media is similar; however, some of it is different, so you will need to store each media type in its own library.

GUI Interface

Your partner has already been through all the inventory. He has created two text files containing all the necessary information to catalogue your media. However, your business needs to have a way of searching through the media without looking through text files. Luckily, the former owners have left behind a partially completed graphical interface. The user layout is already completed. All that is left to finish is the basic storage of the media information and the interaction of the GUI and storage classes.

Requirements

Part 1 - Store it (10 points)

  • Implement the CD and Book interfaces. (5 points per class)

Part 2 - View it (20 points)

  • Implement the Media interface (1 point per method, 20 for a fully functional class). Your implementation of the Media interface must use arrays.

Requirement Notes

Files

  • The files you will need for this lab are all contained an Eclipse project that can be downloaded here. Here is a description of each individual file. Do not modify any of the provided files:
    • cds.txt and books.txt - text files containing the information of all the media for your store.
    • CDInterface.java and BookInterface.java - interfaces that describe what information will need to be stored and how this information will be retrieved for each type of media
    • MediaInterface.java - interface that describes how to interact between the GUI and your storage classes
    • CougarMediaStore.java - the driver for this program
    • MediaDisplay.java - The main panel for the GUI and other necessary private classes
  • You do not need to inspect MediaDisplay.java to understand its functionality. You can complete the lab without looking at that file and parts of it are beyond your comprehension at this point in the course.

Sample Program

  • A sample program can be downloaded here. To run the program you need only double click on the .jar file. Make sure the two text files are also in the same folder or else no books or CDs will actually be loaded in the program.

File Reading

  • The useDelimiter( ) method of the Scanner class can be very helpful. Use of this method will be one of the first topics covered in help sessions.

Testing

  • In order to interact properly with the GUI files, you will need to name your interface implementations CD, Book, and Media.

Other

  • A good help session question for this lab would be: What are some of the common errors that are associated with arrays?
Designed by Andy Griffin