The following code is the JACK code I have been working to implement drawing of a circle in CPEU emulator:
class Main{
var int x,y;
var int r;
constructor Main(){
let x=7;
let y=7;
let r=3;
do draw(x,y,r);
return this;
}
function void draw(int cx, int cy, int r) {
var int dx, dy;
var int r_squared;
let dy=-r;
let r_squared = r*r;
while(dy<r)
{
let dx = Math.sqrt(r_squared-(dy*dy));
do Screen.drawLine(cx-dx,cy+dy,cx+dx,cy+dy);
let dy = dy+1;
}
return;
}
}
I m getting the following error:
In Main.jack (line 2): Expected }
In Main.jack (line 2): Expected end-of-file
I don't see any areas where my code is wrong but for some reason, I still get this error, please help
The Main class does not have a constructor. It must have a function named main(). See Section 9.2.2. It isn't made explicit, but main() should take no arguments and shouldn't return anything (i.e., be a void function).