import josx.platform.rcx.*; public class JukeBox { // Note[] notes; //void playAllSongs(Keyboard k); //boolean addSong(Song s); public static final int SONG_DELAY = 100; public static final int JBOX_SIZE = 5; public static final boolean DEBUG = true; Song[] songs; int empty; JukeBox(int noofSongs) { songs = new Song[noofSongs]; empty = 0; //next open space in playlist } public static void main(String args[]) { Song calibrate = new Song("0C322B322A322B32"); Song scaleUp = new Song("0C222D222E222F222G222A322B322C34"); Song odeToJoy = new Song("0E222E222F222G222G222F222E222D22" + "2C222C222D222E222E233D211D28"); Song maryLamb = new Song("0E231D231C231D231E231E231E27" + "1D231D231D271E231G231G27" + "1E231D231C231D231E231E231E231E23" + "1D231D231E231D231C27"); Song scaleDown = new Song("0C342B322A322G222F222E222D222C22"); Song twinkle = new Song("0C122C122G222G222A222A222G14" + "2F122F122E122E122D122D122C14"); Keyboard k = new Keyboard('C', 3); JukeBox j = new JukeBox(JBOX_SIZE); Slug.setup(); if (j.addSong(calibrate)) Sound.beep(); if (j.addSong(scaleUp)) Sound.beep(); if (j.addSong(maryLamb)) Sound.beep(); if (j.addSong(odeToJoy)) Sound.beep(); if (j.addSong(scaleDown)) Sound.beep(); if (j.addSong(twinkle)) Sound.beep(); if (DEBUG){ Sound.beepSequence(); Slug.wait(2500); } j.playAllSongs(k, SONG_DELAY); Sound.beepSequence(); } void playAllSongs(Keyboard k, int delay) { for (int i=0; i<=this.empty; i++){ this.songs[i].play(k, delay); if (DEBUG) Sound.beep(); Slug.wait(2500); } } boolean addSong(Song s) { if (this.empty <= JBOX_SIZE){ this.songs[this.empty] = s; this.empty++; return true; } return false; } }