P.44 (Next, update Piano class as follows:)
private String[] whiteKeys
= { "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\\" };
private String[] whiteNotes
= { "3c", "3d", "3e", "3f", "3g", "3a", "3b", "4c", "4d", "4e", "4f", "4g" };
private String[] blackKeys
= { "w", "e", "", "t", "y", "u", "", "o", "p", "", "]" };
private String[] blackNotes
= { "3c#", "3d#", "", "3f#", "3g#", "3a#", "", "4c#", "4d#", "", "4f#" };
public Piano() {
super(800, 340, 1);
for(int i=0; i<12; i++) {
Key key = new Key(whiteKeys[i], whiteNotes[i]+".wav",
"white-key.png", "white-key-down.png");
addObject(key, 22 + 32 + i*63, 140);
}
for(int i=0; i<12-1; i++) { // Add another loop to create black keys
if(!blackKeys[i].equals("")) { // If black key name is not empty
Key key = new Key(blackKeys[i], blackNotes[i]+".wav",
"black-key.png", "black-key-down.png");
addObject(key, 22 + (63/2) + 32 + i*63, 86);
} // Shifted by half-width of white key
}
}