Debian Codegraph @

examples/book/digital-artists/chapter9/Listing9.5.ck

raw
1 // Listing 9.5 Redefining BPM's variables as static
2
3 public class BPM
4 {
5 // global variables // (1) Declaring variables as static makes
6 // them global to all instances of BPM
7 static dur quarterNote, eighthNote, sixteenthNote, thirtysecondNote;
8
9 fun void tempo(float beat) {
10 // beat argument is BPM, example 120 beats per minute
11 60.0/(beat) => float SPB; // seconds per beat
12 SPB :: second => quarterNote;
13 quarterNote*0.5 => eighthNote;
14 eighthNote*0.5 => sixteenthNote;
15 quarterNote*0.5 => thirtysecondNote;
16 }
17 }