class Song extends Object120 { 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 ) { super(t,a,l,c); } /** 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).) */ static boolean fitsOnDisk( Song aSong, double freeMegs ) { return true; } static Song longerOf( Song tune1, Song tune2 ) { return tune1; } static Song mashUp( Song tune1, Song tune2 ) { return tune1; } static void testSongs() { Song s1; s1 = new Song( "Help!", "The Beatles", 122.3, true ); Song s2; s2 = new Song( "Yes", "Coldplay", 7*60+7, true ); testEqualBools( fitsOnDisk(s1, 2.0), true ); testEqualBools( fitsOnDisk(s2, 2.0), false ); testEqualBools( fitsOnDisk(s1, 0.0), false ); testEqualBools( fitsOnDisk(s2, 0.0), false ); // new Song("sound of silence","anonymous",0,false) } /** If two booleans aren't equal, print an error message. * Intended for use as a test-helper. * @param act The actual boolean returned by a test call. * @param exp The expected boolean to be returned by a test call. */ static void testEqualBools(boolean act, boolean exp) { if (act==exp) { System.out.println("(test passed)"); } else { System.out.println( "Actual: " + act + "\nExpect: " + exp ); } } /** If two Songs aren't equal, print an error message. * Intended for use as a test-helper. * @param act The actual Song returned by a test call. * @param exp The expected Song to be returned by a test call. */ static void testEqualSongs(Song act, Song exp) { if (equals(act,exp)) { System.out.println("(test passed)"); } else { System.out.println( "Actual: " + act + "\nExpect: " + exp ); } } /** If two Strings aren't equal, print an error message. * Intended for use as a test-helper. * @param act The actual String returned by a test call. * @param exp The expected String to be returned by a test call. */ static void testEqualStrings(String act, String exp) { if (equals(act,exp)) { System.out.println("(test passed)"); } else { System.out.println( "Actual: " + act + "\nExpect: " + exp ); } } }