有没有在Java中制作迷宫布局的特定方法?

huangapple go评论97阅读模式
英文:

Is there a specific way to make a maze layout in Java?

问题

以下是翻译好的内容:

我尝试在Java中制作一个迷宫布局,但一直遇到错误。我已经修复了一些简单的错误,但是我无法消除其他错误。每次我改变代码,甚至菜单都不会显示出来。以下是我遇到的一些错误。

  1. Main.java:53: 错误: 预期 '}'
  2. "3[40mblack3[49m";
  3. ^
  4. Main.java:54: 错误: 不是语句
  5. "3[41mred3[49m"};
  6. ^
  7. Main.java:54: 错误: 预期 ';'
  8. "3[41mred3[49m"};
  9. ^
  10. Main.java:59: 错误: 预期 <标识符>
  11. custom.initializeOptions();
  12. ^
  13. Main.java:60: 错误: 预期 <标识符>
  14. System.out.println("Enter integer choice for width: ")
  15. ^
  16. Main.java:60: 错误: 非法的类型开始
  17. System.out.println("Enter integer choice for width: ")
  18. ^
  19. Main.java:62: 错误: 预期 <标识符>
  20. mapheight = custom.intInput(20,100);
  21. ^
  22. MazeLayout.java:6: 错误: 无效的方法声明; 需要返回类型
  23. public Mazelayout()
  24. ^
  25. MazeLayout.java:63: 错误: 预期 <标识符>
  26. System.out.print("3[0m");
  27. ^
  28. MazeLayout.java:63: 错误: 非法的类型开始
  29. System.out.print("3[0m");
  30. ^
  31. MazeLayout.java:65: 错误: 预期 接口或枚举
  32. }
英文:

I have tried making a maze layout in java but I keep getting errors. I have fixed the simple errors but I cannot get the other errors to go away. Every time I change the code like, even the menu won't show up.
Here are some of the errors I have.

  1. Main.java:53: error: &#39;}&#39; expected
  2. &quot;3[40mblack3[49m&quot;;
  3. ^
  4. Main.java:54: error: not a statement
  5. &quot;3[41mred3[49m&quot;};
  6. ^
  7. Main.java:54: error: &#39;;&#39; expected
  8. &quot;3[41mred3[49m&quot;};
  9. ^
  10. Main.java:59: error: &lt;identifier&gt; expected
  11. custom.initializeOptions();
  12. ^
  13. Main.java:60: error: &lt;identifier&gt; expected
  14. System.out.println(&quot;Enter integer choice for width: &quot;)
  15. ^
  16. Main.java:60: error: illegal start of type
  17. System.out.println(&quot;Enter integer choice for width: &quot;)
  18. ^
  19. Main.java:62: error: &lt;identifier&gt; expected
  20. mapheight = custom.intInput(20,100);
  21. ^
  22. MazeLayout.java:6: error: invalid method declaration; return type required
  23. public Mazelayout()
  24. ^
  25. MazeLayout.java:63: error: &lt;identifier&gt; expected
  26. System.out.print(&quot;3[0m&quot;);
  27. ^
  28. MazeLayout.java:63: error: illegal start of type
  29. System.out.print(&quot;3[0m&quot;);
  30. ^
  31. MazeLayout.java:65: error: class, interface, or enum expected
  32. }

答案1

得分: 1

你需要为一个方法提供一个返回类型(第一个错误),否则它会被视为构造函数。

其余部分可能是稍后的语法错误,编译器无法确定如何恢复正常。

换句话说,你的源代码有问题。请考虑重新学习类定义。

英文:

You need to provide a return type for a method (the first error) or it is considered a constructor.

The rest is probably a syntax error a bit later from which the compiler cannot figure out how to get back on track.

In Other words - your source is broken. Consider studying class definitions again.

huangapple
  • 本文由 发表于 2020年10月21日 02:16:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/64451115.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定