Skip to content

Commit b561f30

Browse files
committed
Add Desert Island Playlist solution
1 parent c66c801 commit b561f30

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

.DS_Store

0 Bytes
Binary file not shown.

5-arrays-arraylists/Playlist.java

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import java.util.ArrayList;
2+
3+
class Playlist {
4+
5+
public static void main(String[] args) {
6+
// creating playlist
7+
ArrayList<String> desertIslandPlaylist = new ArrayList<String>();
8+
9+
// adding songs to playlist
10+
desertIslandPlaylist.add("Sneaker Pimps - Six Undergound");
11+
desertIslandPlaylist.add("A Tribe Called Quest - Electric Relaxation");
12+
desertIslandPlaylist.add("Buena Vista Social Club - Murmullo");
13+
desertIslandPlaylist.add("Little Dragon - Blinking Pigs");
14+
desertIslandPlaylist.add("MF DOOM - Guinnesses");
15+
desertIslandPlaylist.add("Radiohead - Idioteque");
16+
desertIslandPlaylist.add("Erykah Badu - Drama");
17+
desertIslandPlaylist.add("Gramatik - Good Evening, Mr. Hitchcock");
18+
desertIslandPlaylist.add("Jean Grae - Threats");
19+
desertIslandPlaylist.add("The Modern Jazz Quartet - Django");
20+
21+
// printing playlist
22+
// System.out.println(desertIslandPlaylist);
23+
24+
// checking playlist size
25+
// System.out.println(desertIslandPlaylist.size());
26+
27+
// removing songs
28+
desertIslandPlaylist.remove("Gramatik - Good Evening, Mr. Hitchcock");
29+
desertIslandPlaylist.remove("Erykah Badu - Drama");
30+
desertIslandPlaylist.remove("The Modern Jazz Quartet - Django");
31+
desertIslandPlaylist.remove("MF DOOM - Guinnesses");
32+
desertIslandPlaylist.remove("Jean Grae - Threats");
33+
34+
// System.out.println(desertIslandPlaylist);
35+
36+
// swapping songs
37+
int indexA = desertIslandPlaylist.indexOf("Buena Vista Social Club - Murmullo");
38+
int indexB = desertIslandPlaylist.indexOf("A Tribe Called Quest - Electric Relaxation");
39+
40+
String tempA = "Buena Vista Social Club - Murmullo";
41+
42+
desertIslandPlaylist.set(indexA, "A Tribe Called Quest - Electric Relaxation");
43+
// System.out.println(desertIslandPlaylist);
44+
desertIslandPlaylist.set(indexB, tempA);
45+
System.out.println(desertIslandPlaylist);
46+
47+
}
48+
49+
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ $ java HelloWorld
7676

7777
**Desert Island Playlist:**
7878

79-
- [ ] TBD
79+
- [ ] [`Playlist.java`](5-arrays-arraylists/Playlist.java)
8080

8181
### Java Style Guides ###
8282

0 commit comments

Comments
 (0)