-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuntime.java
More file actions
56 lines (48 loc) · 1.18 KB
/
Runtime.java
File metadata and controls
56 lines (48 loc) · 1.18 KB
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
56
import java.util.*;
public class Runtime{
private SongList songs;
private Contestant player;
private SetupScreen startup;
private Buttonswithreturns main;
private int answer;
private AdvancedMP3 musicPlayer;
private FinalFrame end;
public Runtime(){
songs = new SongList("./Songs");
player = new Contestant();
answer = 0;
startup = new SetupScreen(this);
main = new Buttonswithreturns(this);
end = new FinalFrame(this);
startup.run();
}
public void newSong(){
ArrayList<String> songList= songs.get4RandomSongs();
main.setButtons(songList);
int song = (int)(Math.random() * 4);
answer = song;
musicPlayer = new AdvancedMP3(songs.getSongPath(songList.get(song)));
musicPlayer.play(380);
}
public void runMainFrame(String name, int rounds){
player.changeName(name);
player.setNumRounds(rounds);
main.run();
newSong();
}
public void round(int guess){
musicPlayer.close();
if (guess == answer)
player.addScore();
player.setNumRounds(player.getNumRounds() - 1);
if (player.getNumRounds() > 0)
newSong();
else{
main.setVisible(false);
end.run(player.getScore() + "");
}
}
public static void main(String[] args) {
new Runtime();
}
}