簡體   English   中英

在Java初學者中繪制矩形

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM