forked from NeilAlishev/SpringCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMusicPlayer.java
More file actions
39 lines (28 loc) · 783 Bytes
/
MusicPlayer.java
File metadata and controls
39 lines (28 loc) · 783 Bytes
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
package ru.alishev.springcourse;
import org.springframework.beans.factory.annotation.Value;
import java.util.List;
import java.util.Random;
/**
* @author Neil Alishev
*/
public class MusicPlayer {
@Value("${musicPlayer.name}")
private String name;
@Value("${musicPlayer.volume}")
private int volume;
private List<Music> musicList;
public MusicPlayer(List<Music> musicList) {
this.musicList = musicList;
}
public String getName() {
return name;
}
public int getVolume() {
return volume;
}
public String playMusic() {
Random random = new Random();
return "Playing: " + musicList.get(random.nextInt(musicList.size())).getSong()
+ " with volume " + this.volume;
}
}