Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I take an error with my codes how can I fix this kind of error points) You are going to develop a class to represent
I take an error with my codes how can I fix this kind of error
points) You are going to develop a class to represent Songs. *For the instance variables, add the below ones. Make sure that these values cannot be accessed from other classes. Name of the artist Name of the song Duration of the song(in seconds) Play count *Write at least two constructors (not the default one) (Hint: When you first create a song, play count should be 0) *For this class, make sure you follow the encapsulation rules. (Add methods that you think are necessary for encapsulatic *Add an additional play method that increases the play count. *Override the toString method. Return everything in a proper format. *Implement a class that will represent a Music Album that contains songs. *For the instance variables, add the below ones. Make sure that these values cannot be accessed from other classes. name of the album number of songs songs[] *Write at least two constructors (not the default one) *For this class, make sure you follow the encapsulation rules. (Add methods that you think are necessary for encapsulation) *Write one additional method to add songs to this album. *Write one additional method to search a song by the artist's name in this album. If you can find it, return it. *Write one additional method to search a song by the song name in this album. If you can find it, return it. *Write another method to decide the top song in this album which is the most played song and display it. *Override the toString method. Return everything including the song names. *Finally, use this class with a main method. Create a couple of songs. Then create an album with these songs. Play them randomly. Search the songs, call the necessary methods and at the end show us which song is the top song. The general flow is up to you but make sure you call search methods, play method, add method and tostring methods. WHEN YOU COPY PASTE TO THE BELOW AREA, THE FOR SHOULD BE LIKE THIS OPY THE SONG CLASS (ADD THIS DASHES TO SEPERATE THE CLASSES COPY THE ALBUM CLASS (ADD THI EPERATE THE CLASSES COPY YOUR MAN METHOD Album.java testii.java 60 1 2 public class song Song> { 3 private String artistName; 4 private String songName; 5 private int duration; 6 private int playCount; 7 8 90 public song (String artistName String songName , int duration) { 10 this.artistName = artistName; 11 this, songName = songName; 12 this, duration : duration; 13 } 140 public song( String artistName, String songName, int duration, int playCount ) { 15 this.artistName = artistName; 16 this, songName = songName; 17 this, duration = duration; 18 this.playCount = playCount; 19 } 200 public String getArtistName() { 21 return artistName; 22 } 230 public void setArtistName(String artistName) { 24 this.artistName = artistName; 25 } 26 public String getSongName() !! 27 return songName; 28 } 29 public void setSongName(String songName) { this, songName = songName; 31 } 32 public int getDuration() { 33 return duration; 34 } 350 public void setDuration(int duration) { 36 this, duration = duration; 37 } 380 public int getPlayCount() { 30 public String getArtistName() { return artistName; Be public void setArtistName(String artistName) { this.artistName = artistName; 50 public String getSongName() return songName; 3 30 public void setSongName(String songName) { this.songName = songName; 2 public int getDuration() { 3 return duration; 50 public void setDuration(int duration) { 6 this. duration = duration; 7} 80 public int getPlayCount() { return playCount; -10 public void setPlayCount(int playCount) { -2 this.playCount = playCount; 13 } 14 15 @Override 16 public String toString() { 17 return "Song(artistName=" + artistName + SongName=" + songName + ",Duration=" + duration + ", PlayCount=" + playCount + "1" ; 18 79} 500 public void play(@SuppressWarnings("rawtypes") song s) { 51 s.playCount++; 52 } 53 54 9 55 O.JOVE program.jave song.java Album.jave testii java 60 import java.util.ArrayList; import java.util.List; public class Album private String albumName; private int numberOfSongs: @SuppressWarnings("rawtypes") private ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started