import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; class Musician { protected String name; protected String number; protected String address; public Musician(String name, String number, String address) { this.name = name; this.number = number; this.address = address; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } } class Group{ protected Musician[] group = new Musician[10]; public Group(){ } public Group(Musician[] group) { this.group = group; } public Musician[] getGroup() { return group; } public void setGroup(Musician[] group) { this.group = group; } } abstract class AudioDevice{ protected Group group; protected String albumName; public abstract String[] getTracks(); public abstract double getLength(); @Override public String toString() { return "Group: " + group + ", Album name: '" + albumName; } public Group getGroup() { return group; } public void setGroup(Group group) { this.group = group; } public String getAlbumName() { return albumName; } public void setAlbumName(String albumName) { this.albumName = albumName; } } class Song{ protected int number; protected double songLength; protected String name; public Song(int number, double songLength, String name) { this.number = number; this.songLength = songLength; this.name = name; } public int getNumber() { return number; } public void setNumber(int number) { this.number = number; } public double getSongLength() { return songLength; } public void setSongLength(double songLength) { this.songLength = songLength; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return "Number: " + number + ", Length of the song: " + songLength + ", Name of the song: '" + name + '\n'; } } class CD extends AudioDevice{ protected Song[] songs = new Song[30]; public CD(){ } public CD(Song[] songs) { this.songs = songs; } public String[] getTracks(){ String[] songNames = new String[30]; for(int i = 0; i < 30; i++) { songNames[i] = songs[i].getName(); } return songNames; } public double getLength(){ double totalLength = 0; for (Song song: songs){ totalLength += song.getSongLength(); } return totalLength; } public Song[] getSongs() { return songs; } public void setSongs(Song[] songs) { this.songs = songs; } @Override public String toString() { StringBuilder str = new StringBuilder(); for(Song song: this.songs){ str.append(song.toString()); } return super.toString() + str; } } class Store{ ArrayList albums = new ArrayList<>(); public Store(){ } public Store(ArrayList albums) { this.albums = albums; } public void addAlbum(CD albumToAdd){ this.albums.add(albumToAdd); } public void printByMusician(Musician musicianToSearch){ for(CD album: this.albums){ for (Musician musician: album.getGroup().getGroup()){ if(musician.equals(musicianToSearch)){ System.out.println(album); } } } } }