Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 1 Description: In this project, you will be creating a Linked List based song player, see Figure 1. You will be provided with a

image text in transcribed Project 1 Description: In this project, you will be creating a Linked List based song player, see Figure 1. You will be provided with a fully functional Mp3 player that uses arraylists as its underlying data structure. Your task is to completely replace the arraylist and its methods with the Linked List equivalents. The Mp3Player.java le contains all code related to the GUI and playing of Mp3 les, as well as a main class that will test the data structure. You do not modify this le. In fact, you do not even need to understand all of the details of the Mp3Player.java le. However, you will need to completely rewrite the List.java le so that it uses Linked Lists. For your reference, I am using the javazoom mp3 decoder which is imported in the following way, import javazoom.jl.player.*; // This is the MP3 decoder and player import java.io.FileInputStream; // This allows us to read les from disk For Eclipse, here are the instructions for adding the javazoom mp3 player to your classpath: Drag and drop the jar le into your /src folder. Right-click the project and select Properties under the Java Build Path menu, select the Libraries button On the right-hand side, press the Add jars button and add the javazoom jar from your project source folder If you are having trouble getting music to play, you may need to modify one line in Mp3Player.java by adding the complete directory path in front of the String \song" that is passed into new FileInputStream(). For example, a Mac user would change FileInputStream fis = new FileInputStream(song); to contain the path to your source folder: FileInputStream fis = new FileInputStream("/Users/YOURUSERNAME/Documents/workspace/ LASTNAME project1/src/" + song); Part 1 - List.java For the List, you will be creating a singly linked list with the following methods 1. void insertItem (String name) - This method will insert a String item to the end of the linked list. 2. void insertItem (String name, int pos) - This method will insert a String item to the given position in the linked list. You can assume that a position of 0 means the front of the list. (if position is out of bounds, do not insert, but output out of bounds) Figure 1: Visualization of the Mp3 player and correct song ordering. 3. boolean removeItem( String aname) - This method will nd the String with the same value as aname and remove the rst occurrence of that string from the list. The return of this method is either true (success) or false if the string does not exist in the list. Use the .equals method when comparing strings. 4. void removeItem(int position) - Remove the node at position (if position is out of bounds, do not remove, but output out of bounds) 5. boolean contains(String name) - Return true if the linked list contains the string. 6. void clear() - Remove all of the elements from the linked list 7. String get(int index) - Return the element at the speci ed position in the list. 8. int size() - Returns the number of elements in this list. 9. String toString() - Override the toString method to print out the names of all the songs in the list 10. String toHTMLString() -Return a String that starts with ends with and uses the line breaks, , in replacement of new line characters and prints out all the names of all the songs in the list. See the current implementation for details. Next, create a LLNode class in a new java le with elds name and link of type String and LLNode, respectively. You will additionally be creating three constructors, 1. public LLNode() - constructor with no parameters, songName should be an empty string 2. public LLNode(String name) - constructor with 1 parameter, set the name of the song le 3. public LLNode(String name, LLNode next) - constructor with 2 parameters, name of the song and the next node in the list Deliverables: Submit the \lastname project01.zip" le containing List.java, LLNode.java, and your report on Blackboard. //List Class public class List { /////////////////////////////////////////////////// /////////////////////////////////////////////////// ////// Replace this arraylist implementation/ /////// ////// with a Linked List implementation /////////// /////////////////////////////////////////////////// ////////////////////////////////////////////////// String[] alist; // String alist[]; int ind; // holding the last element in my list public List() { // constructors always have the same name as the class alist = new String[2]; ind = -1; // nothing in my list } public void insertItem(String aname) { if(ind+1 == alist.length) {//about to go out of bounds String[]newlist = new String[alist.length*2]; //doubling the array size for(int i=0;i newlist[i] = alist[i]; } alist = newlist; } alist[ind+1] = aname; ind++; } public void insertItem(String aname, int pos) { if(ind+1 == alist.length) {//about to go out of bounds String[] newlist = new String[alist.length*2]; // doubling the array for(int i=0;i newlist[i] = alist[i]; } alist = newlist; } if(pos == ind+1) { alist[pos] = aname; ind++; } else if(pos ind+1) { System.out.println("Not a valid position"); } else if(pos pos; i--) { alist[i] = alist[i-1]; } alist[pos] = aname; ind++; } } public void removeItem(int pos) { if(pos == ind) { alist[pos] = null; ind--; } else if(pos ind) { System.out.println("Not a valid position"); } else if(pos Part 1 - List.java (80 points) For the list, you will be creating singly linked list with the following methods 1. void insertItem (String name) -This method will insert a String item to the end of the linked list 2. void insertItem (String name, int pos) - This method will insert a String item to the given position in the linked list. You can assume that a position of 0 means the front of the list. (if position is out of bounds, do not insert, but output out of bounds) Song Name: col me maybe mp3 Play Stop ext playList macarenamp3 who let the dogs outmp3 chandelier.mp3 mmmbop.mp3 Figure1: Visualization of the Mp3 player and correct song ordering. 3. boolean removeItem String aname) - This method will find the String with the same value as aname and remove the first occurrence of that string from the list. The return of this method is either true (success) or false if the string does not exist in the list. Use the .equals method when comparing strings 4. void removeItem(int position) Remove the node at position (if position is out of bounds, do not remove, but output out of bounds) 5. boolean contains(String name) Return true if the linked list contains the string. 6. void clear) - Remove all of the elements from the linked list 7. String get(int index) - Return the element at the specified position in the list 8. int size) - Returns the number of elements in this list 9. String toStringO -Override the toString method to print out the names of all the songs in the list 10. String toHTMLString) -Return a String that starts with ends with and uses the line breaks, , in replacement of new line characters and prints out al the names of all the songs in the list. See the current implementation for details Next, create a LLNode class in a new java file with fields name and link of type String and LLNode respectively. You will additionally be creating three constructors, 1. public LLNode) - constructor with no parameters, songName should be an empty string 2. public LLNode (String name) constructor with 1 parameter, set the name of the song file 3. public LLNode (String name, LLNode next) - constructor with 2 parameters, name of the song and the next node in the list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago