import java.util.Scanner; class Song { String title; String artist; double length; boolean isCopyrighted; /** Constructor. * @param title The song's title. * @param artist The name of performer/band. * @param length running time, in seconds. * @param isCopyrighted Is this song under copyright? */ Song( String t, String a, double l, boolean c ) { this.title = t; this.artist = a; this.length = l; this.isCopyrighted = c; } Song( Scanner s ) { this( s.nextLine(), s.nextLine(), s.nextDouble(), s.nextBoolean() ); //System.err.println("Read: " + this.toString() ); s.nextLine(); // read past the EOL after the bool we just read; s.nextLine(); // now read past the blank line } /** Can a song fit into the given free space on a disk? * @param a The song to try to fit. * @param freeMegs the amount of free space to fit into, in MB. * @return whether `aSong` fits into `freeMegs` MB of disk space. * (For class purposes: 1 minute requires 1MB (that's plausible for mp3).) */ boolean fitsOnDisk( double freeSpace ) { return (this.length*MB_PER_SEC <= freeSpace); } static double MB_PER_SEC = 1.0/60.0; boolean isLongerThan( /* Song this, */ Song tune2 ) { return this.length > tune2.length; } static Song mashUp( Song tune1, Song tune2 ) { return tune1; } public boolean equals( Song that ) { return this.title.equals(that.title) && this.artist.equals(that.artist) && this.length==that.length && this.isCopyrighted==that.isCopyrighted; } public String toString() { return "Song(" + "\"" + this.title + "\"" + ", \"" + this.artist + "\"" + ", " + this.length + ", " + this.isCopyrighted + ")"; } }