I need help with a piano I'm making for my programming class. Every time I try to compile I get the error
"found int but expected boolean" on my methods with "if" used. Can you guys help me fix this?
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot) /** * A piano that can be played with the computer keyboard. * * @author: Jonah Verner * @version: 0.1 */ public class Piano extends World { /** * Make the piano. */ public Piano() { super(800, 340, 1); makeKeys(); } public void makeKeys() { int i; int keyWidth; int keyHeight; int spaceAtEdge; int KeyNum = 0; Key key = new Key(" ", " "); keyWidth = key.getImage().getWidth(); keyHeight = key.getImage().getHeight(); spaceAtEdge = (800 - keyWidth*12) / 2; String Note = ""; String Letter = ""; if (KeyNum = 0) { Note = "2a#.wav"; Letter = "a"; KeyNum++; } if (KeyNum = 1) { Note = "2a.wav"; Letter = "s"; KeyNum++; } if (KeyNum = 2) { Note = "2b.wav"; Letter = "d"; KeyNum++; } if (KeyNum = 3) { Note = "2c#.wav"; Letter = "f"; KeyNum++; } if (KeyNum = 4) { Note = "2c.wav"; Letter = "g"; KeyNum++; } if (KeyNum = 5) { Note = "2d#.wav"; Letter = "h"; KeyNum++; } if (KeyNum = 6) { Note = "2d.wav"; Letter = "j"; KeyNum++; } if (KeyNum = 7) { Note = "2e.wav"; Letter = "k"; KeyNum++; } if (KeyNum = 8) { Note = "2f.wav"; Letter = "l"; KeyNum++; } for (i=0; i<12; i++) { addObject (new Key (Letter, Note), keyWidth*i + spaceAtEdge + keyWidth/2, keyHeight / 2); } } }
switch(KeyNum) { case 0: Note = "2a#"; Letter = "a"; break; case 1: Note = "2a"; Letter = "s"; break; case 2: Note = "2b"; Letter = "d"; break; //...Etc (fill in the rest)... case 7: Note = "2e"; Letter = "k"; break; case 8: Note = "2f"; Letter = "l"; } } Note += ".wav";