[英]draw rectangle in java beginner
我正在尝试修改当前绘制正方形的方法:
length = 100;
int index = 1;
while (index <= 4) {
tParam.forward(length);
tParam.turn(90);
index++;
}
基本上无法找出要更改的内容tParam.turn();
至。 救命?
这应该工作:
int height = 100; //the height of the rectangle
int width = 200; //the width of the rectangle
for(int i = 0; i < 2; i++) //repeat the following twice
{
tParam.forward(height); //go forward the height of the rectangle
tParam.turn(90); //turn 90 degrees
tParam.forward(width); //go forward the width of the rectangle
tParam.turn(90); //turn 90 degrees
} //end loop
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.