Question: Add to the main method given on this page so you will ALSO do the following (in addition to what is already in main): (I

Add to the main method given on this page so you will ALSO do the following (in addition to what is already in main): (I suggest you use the code given in the LabExercise1.3-CodeFile.txt )

1. call the musicList's add method to insert a new Music object (make up 2 Strings and an int) to the BEGINNING of the musicList

2. assign to a local Music variable a new Music object with the same 2 Strings you just used in #1 of this exercise

3. call contains passing the local Music variable you assigned in #2 of this exercise

4. display the entry if found, or "not found" if not found

5. call display for the musicList

6. call remove to remove the local Music object you created in #2 of this exercise

7. call display for the musicList again.

//Main method

 public static void main( String [] args ) { Music [] musicArray = { new Music("Moonlight Sonata", "Beethoven", 27), new Music("Brandenburg Concerto #3", "Bach", 1048), new Music("Prelude in e minor", "Chopin", 28) }; LList musicList = new LList(); // creates LinkedList! Music tempMusic; 
 System.out.println(" The list as displayed in LList.java: "); displayArray(musicArray);// template is Music here for( int i=0; i < 3; ++i ) musicList.add(musicArray[i]); musicList.display(); tempMusic = musicList.getEntry(2); if( tempMusic != null ) System.out.println(" Found " + tempMusic.getTitle() ); else System.out.println( " Unable to find " + musicArray[1].getTitle() ); // you'll need to test more in an exercise! } // end main 

//Lab exercise 1.3

 public static void main( String [] args ) { Music [] musicArray = { new Music("Moonlight Sonata", "Beethoven", 27), new Music("Brandenburg Concerto #3", "Bach", 1048), new Music("Prelude in e minor", "Chopin", 28) }; LList musicList = new LList(); // creates LinkedList! Music tempMusic; 
 System.out.println(" The list as displayed in LList.java: "); displayArray(musicArray);// template is Music here for( int i=0; i < 3; ++i ) musicList.add(musicArray[i]); musicList.display(); tempMusic = musicList.getEntry(2); if( tempMusic != null ) System.out.println(" Found " + tempMusic.getTitle() ); else System.out.println( " Unable to find " + musicArray[1].getTitle() ); // you'll need to test more in an exercise! } // end main 

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!