class Song3 extends Object120 { private String artist; private String title; private double length; // running time, in s. private boolean isCopyrighted; public static final double MB_PER_SEC = 3.0; // the "constructor": public Song3( String a, String t, double l, boolean isC ) { // Song3 this = /* a Song3 object w/ all fields "zero-ish" */; // implicit -- don't write it! this.artist = a; this.title = t; this.length = l; this.isCopyrighted = isC; // return this; // implicit -- don't write it! } /** return whether `s` can be stored using `space` disk-space. * @param s the song to consider * @param space the amount of available space it has to fit into, in B. */ public boolean willFit( /*Song3 thiss,*/ int space ) { return this.getDiskSpace() <= space; } /** @return how much space this song takes on disk, as an mp3, in B. */ public double getDiskSpace( /* Song3 this */ ) { return (this.getLength()/60.0) * MB_PER_SEC * Math.pow(2,20); } /** return whether one song is shorter than another. * @return whether s1 is shorter than s2. */ public boolean isShorter( /*Song3 this,*/ Song3 that ) { return (this.getLength() < that.getLength()); } String getArtist( /*Song3 this */ ) { return this.artist; } String getTitle( /*Song3 this */ ) { return this.title; } public double getLength( /*Song3 this */ ) { return this.length; } public boolean getIsCopyrighted( /*Song3 this */ ) { return this.isCopyrighted; } private void setArtist( /* Song3 this, */ String newArtist ) { this.artist = newArtist; } private void setTitle( /* Song3 this, */ String newTitle ) { this.title = newTitle; } /** @param newLength -- must be >= 0 */ private void setLength( /* Song3 this, */ double newLength ) { if (newLength < 0) { throw new IllegalArgumentException("length can't be negative!"); } this.length = newLength; } public void setIsCopyrighted( /* Song3 this, */ boolean newIsCopyrighted ) { this.isCopyrighted = newIsCopyrighted; } /** return a remix of a song. * @return `orig` remixed by D.J. `dj`, who added `newMaterialLength` seconds of ill beatz. */ Song3 remix( /* Song3 this, */ String dj, double newMaterialLength ) { return new Song3( this.getArtist() + " vs " + dj, this.getTitle() + " (" + dj + " remix)", this.getLength() + newMaterialLength, false ); } static void testAll() { // some examples of Song3 objects: Song3 s1 = new Song3("Lil Nas X", "Old Town Road", 120, true); Song3 s2 = new Song3("Abba", "Ring Ring", 180, true); Song3 s2a = new Song3("Abba", "Ring Ring", 180, true); assertEquals( s1.isShorter(s2), true ); assertEquals( s2.isShorter(s1), false ); assertEquals( s1.isShorter(s1), false ); assertEquals( s1.willFit(4000), false); printTestMsg("remix"); assertEquals( new Song3( "Lil Nas X vs ibarland", "Old Town Road (ibarland remix)", 150, false ), s1.remix("ibarland", 30) ); assertEquals( new Song3("Abba vs saltman", "Ring Ring (saltman remix)", 180, false), s2.remix("saltman", 0) ); assertEquals( s1.getIsCopyrighted(), true ); s1.setIsCopyrighted(false); assertEquals( s1.getIsCopyrighted(), false ); printTestSummary(); } public static void main( String[] args ) { testAll(); } }