Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help creating a java program. These were the instructions given. Create a

ID: 3768943 • Letter: I

Question

I need help creating a java program. These were the instructions given.

Create a class MP3 with instance variables for: artist, song, album, track length (in seconds). Provide a constructor with four parameters, get/set methods, and a toString method. The toString method should return a String with MP3 data clearly labeled. The track length should be converted into minutes and seconds in the toString method. For example, 265 seconds would be displayed as 4:25. NOTE that an MP3 cannot have a zero or negative track length. Use the default value of one minute for an invalid track length. Do NOT use exception handling. Create a UML class diagram for the MP3 class.

Create an MP3Collection class with instance variables count and an MP3 ArrayList. The class should have a no-argument constructor, a get method for the count and a toString method that returns the information for all MP3s in the collection. The class will also have an addMP3 method that takes 4 arguments, creates an MP3 object and places it in the MP3 collection (ArrayList). Count each MP3 added to the collection. Create a UML class diagram for the MP3Collection class.

Create a test program MP3CollectionTest that adds AT LEAST 5 MP3s to the MP3 collection. Use literal data for real MP3s. Your failure to use real MP3 data will result in the loss of 1 point. The program outputs the number of MP3s in the collection and the information about all MP3s in the collection. Be sure to clearly label the output and to comment your code. Use a dialog box for output. Your name must appear in the output. Do NOT use the MP3 class in the test program.

Explanation / Answer

public class MP3{ private String artist; private String song; private String album; private int trackLength; public MP3(String artistName, String songName, String albumName, int trackLeng){ setArtist(artistName); setSong(songName); setAlbum(albumName); setTrackLength(trackLeng); } public void setArtist(String artistName){ artist = artistName; } public String getArtist(){ return artist; } public void setSong(String songName){ song = songName; } public String getSong(){ return song; } public void setAlbum(String albumName){ album = albumName; } public String getAlbum(){ return album; } public void setTrackLength(int trackLeng){ trackLength = trackLeng; } public int getTrackLength(){ return trackLength; } public String toString(){ return String.format("%s, %s, %s, %d : %d", getArtist(), getSong(), getAlbum(), getTrackLength() / 60, getTrackLength() - (getTrackLength() / 60) * 60); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote