我的代码风格有什么问题吗? 这是家庭作业,我试图提交,但它说我的风格是错误的:/编码风格有问题
import java.util.Scanner;
public class Groucho {
String secret;
public Groucho(String secret) {
this.secret = secret;
}
public boolean saysSecret(String line) {
if (line.indexOf(secret) != -1)
return true;
else
return false;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter your secret word here: ");
String a = in.nextLine();
Groucho x = new Groucho(a);
System.out.println("Please enter a sentence until you win the game");
while (in.hasNextLine()) {
String inp = in.nextLine();
if (x.saysSecret(inp)) {
System.out.println("You have won $100 for saying " + a);
break;
}
else
System.out.println("Try again");
}
}
}
这就是我的风格检查说是错误的:
Request 1
File received, running checkstyle...
Starting audit...
Groucho.java:20: while child at indentation level 11 not at correct indentation, 12
Groucho.java:21: if at indentation level 11 not at correct indentation, 12
Groucho.java:22: if child at indentation level 15 not at correct indentation, 16
Groucho.java:22: method call child at indentation level 15 not at correct indentation, 16
Groucho.java:23: if child at indentation level 15 not at correct indentation, 16
Groucho.java:24: if rcurly at indentation level 11 not at correct indentation, 12
Groucho.java:25: else at indentation level 11 not at correct indentation, 12
Groucho.java:26: method call child at indentation level 15 not at correct indentation, 16
Audit done.
Done!
一个挑剔:改变'saidSecret()'简单地说就是'return line.indexOf(secret)> = 0;'。 – user949300 2014-09-19 07:09:35
谢谢:)没想到那 – Panthy 2014-09-19 07:10:50
这个问题更适合https://codereview.stackexchange.com/。 – 2014-09-19 07:20:25