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

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

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

问题

以下是翻译好的内容:

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

Main.java:53: 错误: 预期 '}' 
        "3[40mblack3[49m";
                               ^
Main.java:54: 错误: 不是语句 
        "3[41mred3[49m"};
        ^
Main.java:54: 错误: 预期 ';' 
        "3[41mred3[49m"};
                             ^
Main.java:59: 错误: 预期 <标识符> 
  custom.initializeOptions();
                          ^
Main.java:60: 错误: 预期 <标识符> 
  System.out.println("Enter integer choice for width: ")
                    ^
Main.java:60: 错误: 非法的类型开始 
  System.out.println("Enter integer choice for width: ")
                     ^
Main.java:62: 错误: 预期 <标识符> 
  mapheight = custom.intInput(20,100);
           ^
MazeLayout.java:6: 错误: 无效的方法声明; 需要返回类型 
  public Mazelayout()
         ^
MazeLayout.java:63: 错误: 预期 <标识符> 
    System.out.print("3[0m");
                    ^
MazeLayout.java:63: 错误: 非法的类型开始 
    System.out.print("3[0m");
                     ^
MazeLayout.java:65: 错误: 预期 类接口或枚举 
}
英文:

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.

Main.java:53: error: &#39;}&#39; expected
        &quot;3[40mblack3[49m&quot;;
                               ^
Main.java:54: error: not a statement
        &quot;3[41mred3[49m&quot;};
        ^
Main.java:54: error: &#39;;&#39; expected
        &quot;3[41mred3[49m&quot;};
                             ^
Main.java:59: error: &lt;identifier&gt; expected
  custom.initializeOptions();
                          ^
Main.java:60: error: &lt;identifier&gt; expected
  System.out.println(&quot;Enter integer choice for width: &quot;)
                    ^
Main.java:60: error: illegal start of type
  System.out.println(&quot;Enter integer choice for width: &quot;)
                     ^
Main.java:62: error: &lt;identifier&gt; expected
  mapheight = custom.intInput(20,100);
           ^
MazeLayout.java:6: error: invalid method declaration; return type required
  public Mazelayout()
         ^
MazeLayout.java:63: error: &lt;identifier&gt; expected
    System.out.print(&quot;3[0m&quot;);
                    ^
MazeLayout.java:63: error: illegal start of type
    System.out.print(&quot;3[0m&quot;);
                     ^
MazeLayout.java:65: error: class, interface, or enum expected
}

答案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:

确定