Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.time.Duration;
- import java.util.ArrayList;
- public class Album {
- private String name, band;
- private Duration length; // total running time of the whole album
- public Album(String name, String band) {
- this.name = name;
- this.band = band;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getBand() {
- return band;
- }
- public void setBand(String band) {
- this.band = band;
- }
- public Duration getLength() {
- return length;
- }
- public void addSong(Duration length) {
- if (length == null) {
- throw new IllegalArgumentException();
- } else {
- // Add the "length" paramter to the length of the album! Use +=
- }
- }
- public ArrayList <Duration> getSongs() {
- return new ArrayList <Duration>(); // Change this!
- }
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Album) {
- Album that = (Album) obj;
- return this.getName().equalsIgnoreCase(that.getName())
- && this.getBand().equalsIgnoreCase(that.getBand());
- } else {
- return false;
- }
- }
- @Override
- public String toString() {
- return "Album[" +
- "name= " + name + ", " +
- ", band= " + band + ", " +
- ", length= " + length + "]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment