import Turtle; /* create a parent class for Note */ class Note { static int wholeNoteTime = 60; public static int getWholeNoteTime () { return wholeNoteTime; } public static void setWholeNoteTime(int centiseconds) { if(centiseconds >= 0 ) wholeNoteTime = centiseconds; } int pitchIndex; float duration; public Note(int pitchIndex, float duration) { this.pitchIndex = pitchIndex; this.duration = duration; } public Note(float duration) { this.pitchIndex = -1; this.duration = duration; } public void play() { int centiseconds = Math.round(duration*wholeNoteTime); if(pitchIndex == -1) { Turtle.sleep(centiseconds*10); } else { Turtle.playNote(pitchIndex,centiseconds); } } } interface NoteValues { public final int A1 = 28; public final int A1_SHARP = 29; public final int B1_FLAT = 29; public final int B1 = 30; public final int C1 = 31; public final int C1_SHARP = 32; public final int D1_FLAT = 32; public final int D1 = 33; public final int E1 = 35; public final int F1 = 36; public final int G1 = 38; public final int A2 = 40; public final int B2 = 42; public final int C2 = 43; public final int D2 = 45; public final int E2 = 47; } interface NoteTimes { public final float whole = 1.0f; public final float half = 0.5f; public final float quarter = 0.25f; public final float eighth = 0.125f; public final float sixteenth = 0.0625f; } class Task1 implements NoteValues, NoteTimes { public static void main(String args[]) { Note.setWholeNoteTime(120); Note rest = new Note(quarter); Note c = new Note(C1,quarter); Note d = new Note(D1,quarter); Note e = new Note(E1,quarter); Note f = new Note(F1,eighth); Note g = new Note(G1,quarter); e.play(); d.play(); c.play(); rest.play(); e.play(); d.play(); c.play(); rest.play(); g.play(); f.play(); f.play(); e.play(); } }