ThreeFigureMinuetThing.java
|
1 /*
2 Program for assignment 1, problem 3: This program plays
3 a sequence of nine notes without a composer
4 */
5
6 package mmw;
7
8 import note.SNote;
9
10 import javax.swing.SwingUtilities;
11
12
13 public class ThreeFigureMinuetThing {
14
15 private void PlayTheNotes() {
16 SNote note = new SNote();
17 note.text();
18
19 //Plays the first three notes
20 FirstSequence(note);
21 //Plays four notes
22 SecondSequence(note);
23 //Plays the last two notes
24 ThirdSequence(note);
25 }
26
27
28 private static void FirstSequence(SNote note) {
29 //(C,1)
30 note.play();
31
32 //(B,1)
33 note.lp();
34 note.play();
35
36 //(A,1)
37 note.lp();
38 note.play();
39 }
40
41 private static void SecondSequence(SNote note) {
42 //(C,1/2)
43 note.rp(2);
44 note.s2();
45 note.play();
46
47 //(B,1/2)
48 note.lp();
49 note.play();
50
51 //(A,1/2)
52 note.lp();
53 note.play();
54
55 //(B,1/2)
56 note.rp();
57 note.play();
58 }
59
60 private static void ThirdSequence(SNote note) {
61 //(C,1)
62 note.rp();
63 note.x2();
64 note.play();
65
66 //(C,3)
67 note.x3();
68 note.play();
69
70 //(C,1): makes our program invariant
71 note.s3();
72 }
73
74
75 public ThreeFigureMinuetThing() {
76 PlayTheNotes();
77 }
78
79
80
81
82 public static void main(String[] args) {
83 SwingUtilities.invokeLater(new Runnable() {
84 public void run() {
85 new ThreeFigureMinuetThing();
86 }
87 });
88 }
89 }
90
91