我正在尝试使用Turtle Graphics和Java在“世界”窗口中编写文本,但我收到了一些看似无用的错误(例如下面的错误)。
invalid character constant
The method write(String) is undefined for the type Turtle
我的代码非常简短和简单(如下所示),所以我看不出任何事情会被搞糟。最后一行是
import java.util.Scanner; //scanner import javax.swing.JOptionPane; //dialog boxes public class ProjectTwo_Ponyville2 { public static void main(String[] args) { //declare world and turtle World w = new World(800, 600); //world Turtle t = new Turtle(w); //turtle //ask user for name strUserName = JOptionPane.showInputDialog("Enter your name"); System.out.println(strUserName); //print user name in world t.write('" + strUserName + "'); } }
警告一下,我对Turtle Graphics和Java都是新手,所以这可能只是我错过了一些简单的东西。我找到的所有关于Turtle Graphics的在线信息都使用Python,所以没有什么帮助。希望堆栈溢出可以为我解决这个问题!