我得到'其他'沒有'如果'錯誤。 請幫忙,謝謝我得到'其他'沒有'如果'錯誤
class MyGraphics
{
FrameBuffer fb;
int x, y;
private int width, height;
MyGraphics(int wid, int hit)
{
fb= new FrameBuffer(wid,hit);
width = fb.getWidth();
height = fb.getHeight();
}
MyGraphics()
{
fb = new FrameBuffer();
width = fb.getWidth();
height = fb.getHeight();
}
void drawLine(int x1, int y1, int x2, int y2){
int x0;
double y0 = y1;
double slope = (double)(y2 - y1)/(double)(x2 - x1);
if (x2 < width && y2 < height)
{
for (x0 = x1; x0<=x2; x0++)
y0=y0+ slope;
}
fb.setPixel(x0, ((int)y0));
else if(x2 < width && y2 >= height)
{
for(y0=y1,x0=x1; (int)y0< height; x0++)
y0 = y0 + slope;
}
fb.setPixel(x0, ((int)y0));
else if(x2 >= width && y2 <height)
{
for (x0 = x1; x0 < width; x0++)
y0=y0+ slope;
}
fb.setPixel(x0, ((int)y0));
else
{
for(x0=x1; x0 < width && (int)y0 < height;x0++)
y0 = y0 + slope;
fb.setPixel(x0, ((int)y0));
}
return;
}
void display()
{
fb.display();
return;
}
}
如果你想讓你的代碼清晰正確地縮進,那就很明顯了。你錯過了一個}。 – Stellarator
請正確縮進你的代碼,你就會知道這個問題。 –
爲什麼所有的downvotes?我們不能***所有***錯了...... – Mysticial