Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- public class Album {
- private Song[] album = new Song[3];
- private ArrayList<Song> list = new ArrayList<Song>();
- private int songcount;
- private int albumduration;
- public void addSong(Song song) {
- for (int i = 0; i < album.length; i++) {
- if (album[i] == null) {
- album[i] = song;
- songcount++;
- albumduration += song.getDuration();
- break;
- }
- }
- }
- public List<Song> getSongs() {
- return list;
- }
- public int getSongCount() {
- return songcount;
- }
- public int getAlbumDuration() {
- return albumduration;
- }
- public void printSongs() {
- for (int i = 0; i <= list.size(); i++)
- System.out.println(i + album[i].toString());
- }
- public static void main(String[] args) {
- Album hits = new Album ();
- Song a = new Song("Eminem", "shots", 127);
- Song b = new Song("Rihanna", "work", -78);
- Song c = new Song("SnoopDogg", "SWEDEN", 420);
- a.addSong();
- b.addSong();
- c.addSong();
- System.out.println(hits.getSongCount());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement