001package music; 002interface Event { 003 public void play(); 004} 005class Note implements Event { 006 int d; 007 double f; 008 public Note(int duration, double factor) { 009 this.d = duration; 010 this.f = factor; 011 } 012 public void play() { 013 Music.scalePitch(f); 014 Music.play(d); 015 Music.scalePitch(1.0/f); 016 } 017} 018class Rest implements Event { 019 int d; 020 public Rest(int duration) { 021 d = duration; 022 } 023 public void play() { 024 Music.rest(d); 025 } 026}