Question: MediaList.java /* This class encapsulates a list of media items in a user's collection. * The list is implemented as an array of type MediaItem.

MediaList.java

/* This class encapsulates a list of media items in a user's collection. * The list is implemented as an array of type MediaItem. * Media items are either a book (electronic format), movie, or song. * Each type of media item is represented by an instance of the Book, Movie, or Song class. * These three classes are subclasses of MediaItem. The array stores media items as * references of type MediaItem. */ public class MediaList { //Class member variable declarations:

/* Constructor that initializes the member variables. The array is * created using the initial length passed in to the constructor. * The initialLength is assigned to the initial length passed in to the constructor. * The numItems is initialized to 0. * Any other member variables are initialized as well. */ public MediaList(int initialLen){ } /* Add the newItem passed in to the next available cell in the itemList. * Available cells have the vaue NULL. The numItems variable may be used * to keep track of the index of the next available cell. * For example, if the list contained: item1, item2, NULL, NULL, * the next available cell is at index 2. */ public void addItem(MediaItem newItem){ }

/* This method returns an array that contains only MediaItem objects whose * title matches the targetTitle passed in. * The array returned does not contain any NULL values. * This method returns an array of length 0 if there are no matches. * This method may call the getOnlyItems method. */ public MediaItem[] getItemsByTitle(String targetTitle){ return null; } /* This method returns an array that contains only MediaItem objects whose * genre matches the targetGenre passed in. * The array returned does not contain any NULL values. * This method returns an array of length 0 if there are no matches. * This method may call the getOnlyItems method. */ public MediaItem[] getItemsByGenre(String targetGenre){ return null; } /* This method returns an array of all of the MediaItem objects that are * stored in the itemList. The array returned does not contain any NULL * values. This method returns an array of length 0 if the itemList is empty. * This method may call the getOnlyItems metho */ public MediaItem[] getItemList(){ return null; } /* Returns the number of items stored in the itemList. */ public int getNumItems(){ return -5; } /* Returns true if the itemList contains no MediaItems, false otherwise. */ public boolean isEmpty(){ return false; } /****** Private, "helper" method section ******/ /* Creates a new array that is double the size of the array passed in, copies the data * from that array to the new array, and returns the new array. * Note that the new array will contain the items from the previous array followed by NULL values. */ private MediaItem[] expandList(MediaItem[] inputList){ return null; } /* A full item list is an array where all cells contain an item. That * means there is no cell that contains NULL. * This method returns true if all cells in the array contain a String * object, false otherwise. */ private boolean isFull(){ return true; } /* * This method takes an array of MediaItems as an input as well as * the number of MediaItems on that array. The input array may contain * some NULL values. * This method returns an array that contains only the MediaItems in * the input array and no NULL values. * It returns an array of length 0 if there are no MediaItems in the input array. */ private MediaItem[] getOnlyItems(MediaItem[] inputArray, int size){ return null; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!