我正在尝试分解一些代码,以便我可以更好地理解它。这是 String 方法的一个片段
public String randomGame() {
String output = "There were " + Count + " wars\n";
output += player1.getName() + " won " + player1.win() + " cards and " + player1.getTheory() + " theory(s)\n";
output += player2.getName() + " won " + player2.win() + " cards and " + player2.getTheory() + " theory(s)\n";
if(player1.winPerTurn() > player2.winPerTurn()){
output += "Winner: " + player1.getName();
}
else {
output += "Winner: " + player2.getName();
}
return output;
}
就我个人而言,我对这些输出感到不舒服。我已经知道它打印出来了,我的问题是。我有可能以某种方式以 system.out.print 形式重新格式化这个逻辑吗?