forked from eahs/MusicList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMusicLibrary.java
55 lines (47 loc) · 869 Bytes
/
MusicLibrary.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.util.*;
public class MusicLibrary {
private ArrayList<Song> songs;
private int currentSortField = 0; // Unsorted
public MusicLibrary() {
/* YOUR CONSTRUCTOR CODE HERE*/
}
/*
* Add song to songs ArrayList
*/
public void addSong (Song song)
{
}
/*
* Retrieve a song by number
* Return null if song index num is out of bounds
*/
public Song getSong (int num)
{
return null;
}
/*
* Sort song list by title
*/
public void Sort ()
{
currentSortField = field;
}
/*
* Sort song list by a specific field
*
* 1 = title
* 2 = artist
*/
public void Sort (int field)
{
currentSortField = field;
}
/*
* Shuffle song list
*/
public void Shuffle ()
{
long seed = System.nanoTime();
Collections.shuffle(songs, new Random(seed));
}
}