-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodefolyfe.java
More file actions
45 lines (39 loc) · 1.3 KB
/
Copy pathCodefolyfe.java
File metadata and controls
45 lines (39 loc) · 1.3 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
import java.io.File;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.swing.JOptionPane;
public class Codefolyfe {
public static void main(String[] args) {
/*
* Ask the user how many hours they spent coding this week.
*
* 1. If it's 3 or more, tell them they're a Code Ninja. fffffFfF 2. If
* it's less than 2, tell them to stop watching YouTube and write code
* instead.
*
* 3. If it's more than 5, play the Batman theme song.
*/
String hours = JOptionPane.showInputDialog("How many hours have you spent coding this week?");
int hours2 = Integer.parseInt(hours);
if (hours2 >= 3 && hours2 <= 5) {
JOptionPane.showMessageDialog(null, "Welcome to the Coding Ninja Club! :D");
} else if (hours2 < 2) {
JOptionPane.showMessageDialog(null, "Stop watching videos and do some coding! <:P");
} else if (hours2 > 5) {
playBatmanTheme();
}
}
private static void playBatmanTheme() {
try {
AudioInputStream audioInputStream = AudioSystem
.getAudioInputStream(new File("/Users/League/Google Drive/league-sounds/batman.wav"));
Clip clip = AudioSystem.getClip();
clip.open(audioInputStream);
clip.start();
Thread.sleep(60002);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}