CPT120 Tutorial 7 Solved

25.00 $ 12.50 $

Category:
Click Category Button to View Your Next Assignment | Homework

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

Description

Rate this product
  1. Follow the materials under Canvas→ Modules→We ek  7
5.1 Complete this exercise with the help of your group tutor. However, your tutor will not be able to write the code on your behalf. Instead, they will give general guidance.

Get the MusicLibraryW7.java file from Canvas→Discussions→Tutorial Discussions→Class ? (where ? is your group) and get it in to your Eclipse (If you cannot find the file, ask your group tutor). Familiarise yourself with the program first (such as by running and tracing through the code) and then modify it as follows:

1.                   Create a constructor and move all of the code from the main method to the constructor and get the code to work as before. When written correctly, the main method should only contain the following two lines:

MusicLibrary ml; ml=new MusicLibrary();

2.                   Move the declarations of maxNumSongs, songTitles, songLocations and currentNumSongs from the constructor to the class block and make them private. These will be known as object member variables. E.g.

public class MusicLibrary { private int maxNumSongs; private String[] songTitles; private String[] songLocations; private int currentNumSongs;

Note: You must not have any = (equal) signs in front of the above declarations; All object member initialisations must be performed in the constructor. Also, the word ‘static’ must only be used in the main method’s definition.

3.                   In your constructor, add this. (this dot) to the start of any mention of an object member variable name. E.g.

maxNumSongs = 3; Should be changed to:

this.maxNumSongs = 3;

… and so forth for all object member variables (there are many such places).

4.                   Create a method each for the three menu items of the application.

5.                   Move at least one segment of repeated code to its own method. This method should take one or more parameters and return an appropriate value.

Page 1 of 2

  1. Make the necessary changes to make the constructor accept a parameter specifying the maximum number of songs.
  2. Make the necessary changes so that, when adding a song, if a song by the same title already exists, the user is able to specify a new location for the song. When written correctly, this should not result in duplicated entries for the same song title.
  3. Make the necessary changes so that, when adding a song and if out of room, the arrays are expanded. You must not use ArrayList or similar data structures to achieve this functionality. Ask your group tutors if you are not sure.

5.2. Add comments in the style required by Assignment 2. See rubric in section 9 of the Assignment 2 PDF.

  1. If you have not submitted your final version of A2, add comments explaining your plan. Note that this will not be marked but it is to help you progress.
  • Independent_Investigation_Effort_07-qpf25q.zip