目前,我正在为Java类编写打砖块游戏类。我对我的public javafx.scene.paint.Color getColor()方法遇到的一个检查样式错误有疑问,该方法根据被球击中的次数获取砖的颜色。
checkstyle错误说:Return count is 6 (max allowed for non-void methods/lambdas is 2).我认为这意味着我只能有2条返回语句,而我目前只有6条。所有的语句都有不同的返回值,基于这些值this.hits我不了解。其文档如下:
public javafx.scene.paint.Color getColor()
The current color to represent this Brick's breakability state.
Returns:There are five possible Colors that can be returned based on
theBrick's current strength: Color.BLACK if this Brick cannot be
broken;Color.WHITE if this Brick has been completely broken; and
Color.RED, Color.YELLOW,Color.GREEN if this Brick will break after 1, 2,
and 3 more hits, consecutively.
Run Code Online (Sandbox Code Playgroud)
和代码:
public javafx.scene.paint.Color getColor() …Run Code Online (Sandbox Code Playgroud)