Commit 4820de1e authored by Trisha Gee's avatar Trisha Gee
Browse files

Code from p548, had to add a second Jukebox3 class because the book has the...

Code from p548, had to add a second Jukebox3 class because the book has the output coming from Jukebox3
parent 2dd35278
Loading
Loading
Loading
Loading
+19 −0
Changes for src/main/java/Jukebox3Works.java: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
import java.util.ArrayList;
import java.util.Collections;

public class Jukebox3Works {

    ArrayList<SongV3> mySongs;
    MockSongV2File mockFile = new MockSongV2File();

    public static void main(String[] args) {
        new Jukebox3Works().go();
    }

    public void go() {
        mySongs = mockFile.getSongsV3();
        System.out.println(mySongs);
        Collections.sort(mySongs);
        System.out.println(mySongs);
    }
}
 No newline at end of file
+11 −0
Changes for src/main/java/MockSongV2File.java: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -13,4 +13,15 @@ class MockSongV2File {
        mySongs.add(new SongV2("50 ways", "simon", "70"));
        return mySongs;
    }
    public ArrayList<SongV3> getSongsV3() {
        ArrayList<SongV3> mySongs = new ArrayList<>();
        mySongs.add(new SongV3("somersault", "zero 7", "50"));
        mySongs.add(new SongV3("cassidy", "grateful dead", "65"));
        mySongs.add(new SongV3("$10", "hitchhiker", "80"));

        mySongs.add(new SongV3("havana", "cabello", "60"));
        mySongs.add(new SongV3("Cassidy", "grateful dead", "65"));
        mySongs.add(new SongV3("50 ways", "simon", "70"));
        return mySongs;
    }
}
 No newline at end of file
+31 −0
Changes for src/main/java/SongV3.java: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line
class SongV3 implements Comparable<SongV3> {
    String title;
    String artist;
    String bpm;

    public int compareTo(SongV3 s) {
        return title.compareTo(s.getTitle());
    }

    SongV3(String t, String a, String b) {
        title = t;
        artist = a;
        bpm = b;
    }

    public String getTitle() {
        return title;
    }

    public String getArtist() {
        return artist;
    }

    public String getBPM() {
        return bpm;
    }

    public String toString() {
        return title;
    }
}