这是我的代码:
public class Project1mrybak3
{
public static void main (String[] args)
{
System.out.println("Begin Java Exection");
System.out.println("");
// put your Java Program here
//choose picture
String picfile = FileChooser.pickAFile();
Picture pic = new Picture(picfile);
//Create turtle 1
Turtle t1 = new Turtle (pic);
t1.setPenWidth(10);
//Create turtle 2
Turtle t2 = new Turtle (pic);
flower(t1,200);
//show picture
pic.show();
System.out.println("");
System.out.println("End Java Exection");
}//end of main class
public static void flower (Turtle tparam, int x )
{
tparam.forward(x);
}
public static void flowers ()
{
flower(t1,15);
}
} // end of Template class
如您所知,这没有多大意义,但是我才刚刚开始编写它.我的问题是,对于最后一个方法花,当我尝试运行它时,它说找不到符号变量t1.如果我删除参数,它说它需要参数Turtle和int.我不能将方法放入方法内部吗?
最终,我的目标是创建约4种方法来绘制花朵的一部分,然后将它们全部放入一个方法中,然后在我的主代码中,我可以使用turtle t1和一些x变量调用该方法.
感谢您的帮助和您的宝贵时间!