2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
29
Task/Metronome/Java/metronome.java
Normal file
29
Task/Metronome/Java/metronome.java
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
class Metronome{
|
||||
double bpm;
|
||||
int measure, counter;
|
||||
public Metronome(double bpm, int measure){
|
||||
this.bpm = bpm;
|
||||
this.measure = measure;
|
||||
}
|
||||
public void start(){
|
||||
while(true){
|
||||
try {
|
||||
Thread.sleep((long)(1000*(60/bpm)));
|
||||
}catch(InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
counter++;
|
||||
if (counter%measure==0){
|
||||
System.out.println("TICK");
|
||||
}else{
|
||||
System.out.println("TOCK");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class test {
|
||||
public static void main(String[] args) {
|
||||
Metronome metronome1 = new Metronome(120,4);
|
||||
metronome1.start();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue