import java.util.Scanner; class TestSong{ static void testSongs() { Song s1; s1 = new Song( "Help!", "The Beatles", 118.3, true ); Song s2; s2 = new Song( "Yes", "Coldplay", 7*60+7, true ); System.out.println( "Testing starts" ); TestUtils.equalBools( s1.fitsOnDisk( 2.0), true ); TestUtils.equalBools( s2.fitsOnDisk( 2.0), false ); TestUtils.equalBools( s1.fitsOnDisk( 0.0), false ); TestUtils.equalBools( s2.fitsOnDisk( 0.0), false ); TestUtils.equalBools( new Song("sound of silence", "anonymous", 0, false).fitsOnDisk( 0.0 ), true ); } /** 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 (act.equals(exp)) { System.out.println("(test passed)"); } else { System.out.println( "Actual: " + act + "\nExpect: " + exp ); } } static void testMany() throws java.io.FileNotFoundException { Scanner s = new Scanner( new java.io.File("song-data.txt" ) ); // Hack: we rely on the above file containing (at least) 4 songs: Song[] album = new Song[4]; // (A better solution would be to use a List, which can shrink or grow, // rather than an array which is always a fixed size.) for (int i=0; i