CPT120 Tutorial 8 Solved

25.00 $ 12.50 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


Rate this product


  1. Follow the materials under Canvas→ Modules→We ek 8
5.1. With the help of your group tutors via the Canvas→Discussion forums and by using good Object Oriented (OO) coding practices (also required for Assignment 3), convert the MusicLibraryW7.java (from IIE7 or your latest version) to an OO application as per the following description:

Song.java: A Song object cannot be created without a song title and a String containing the location of the song in the computer (e.g. “c:/song.mp3”). It also has the relevant accessor (get) methods but no mutator (set) methods. A Song must not have any methods that will display messages. Only its constructor and the above two methods can be accessed by other classes. Write the code for this in a new class named Song.java.

MusicLibrary.java: A MusicLibrary object cannot be created without a maximum number of songs. A MusicLibrary object also has an array of Song objects (the size of this array can be set to the maximum number of songs specified) and the number of currently added songs. It must not have the separate arrays songTitles and songLocations anymore. Move all of the code from the main method to the constructor first then refactor the code in to different methods so that you have at least one method per menu item. Aside from the methods, no other component of this class should be accessible by other classes. As it is the application class, the MusicLibrary has a main method and this method must contain only the following line (then the return statement):

MusicLibrary ml=new MusicLibrary(100);

In the above, the 100 refers to the maximum number of songs.

Remember, when doing OO in Intro To Prog: Follow the guidelines given in Canvas→Assignments→Assignment 3 (guidelines). You must not create anything static other than public static void main. All object member variables must be private and they must only be initialised inside the constructor (including the creation of arrays). Any references to member variables from within methods should start with “this.”. There is no need for private methods. You will need to write a constructor for each class and you must prevent the creation of objects that are invalid (e.g. don’t create a second constructor that will allow you to create a Song object with no song title or location). Use only standard arrays in Java (e.g. avoid ArrayList, etc.). You must not use break, continue, System.exit(). Use only while loops for repetition. When possible, you must use concepts covered in standard class materials over others.

5.2. Add comments in the style required by Assignment 2/3. See rubric section in Assignment 2/3 PDF.
  • Independent_Investigation_Effort_08-ziov3y.zip