Added Spring Java Conventions to all of the spring sub-projects and formatted them to meet the guidelines.
This commit is contained in:
@@ -20,8 +20,8 @@ import java.util.Calendar;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Action that encapsulates logic for the number guess sample flow. Note that
|
||||
* this is a stateful action: it holds modifiable state in instance members!
|
||||
* Action that encapsulates logic for the number guess sample flow. Note that this is a stateful action: it holds
|
||||
* modifiable state in instance members!
|
||||
*
|
||||
* @author Erwin Vervaet
|
||||
* @author Keith Donald
|
||||
@@ -63,16 +63,13 @@ public class HigherLowerGame implements Serializable {
|
||||
public GuessResult makeGuess(int guess) {
|
||||
if (guess < 0 || guess > 100) {
|
||||
setResult(GuessResult.INVALID);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
guesses++;
|
||||
if (answer < guess) {
|
||||
setResult(GuessResult.TOO_HIGH);
|
||||
}
|
||||
else if (answer > guess) {
|
||||
} else if (answer > guess) {
|
||||
setResult(GuessResult.TOO_LOW);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setResult(GuessResult.CORRECT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ public class MastermindGame implements Serializable {
|
||||
public GuessResult makeGuess(String guess) {
|
||||
if (isGuessValid(guess)) {
|
||||
setResult(calculateResult(guess));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setResult(GuessResult.INVALID);
|
||||
}
|
||||
return getResult();
|
||||
@@ -86,8 +85,7 @@ public class MastermindGame implements Serializable {
|
||||
if (digit == answerDigit) {
|
||||
if (i == j) {
|
||||
rightPosition++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
correctButWrongPosition++;
|
||||
}
|
||||
break;
|
||||
@@ -97,8 +95,7 @@ public class MastermindGame implements Serializable {
|
||||
data.recordGuessData(guess, rightPosition, correctButWrongPosition);
|
||||
if (rightPosition == 4) {
|
||||
return GuessResult.CORRECT;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return GuessResult.WRONG;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ import org.springframework.webflow.samples.numberguess.MastermindGame.GuessResul
|
||||
public class MastermindGameTests extends TestCase {
|
||||
|
||||
private MastermindGame action = new MastermindGame();
|
||||
|
||||
|
||||
protected void setUp() {
|
||||
action = new MastermindGame();
|
||||
}
|
||||
|
||||
|
||||
public void testGuessNoInputProvided() throws Exception {
|
||||
GuessResult result = action.makeGuess(null);
|
||||
assertEquals(GuessResult.INVALID, result);
|
||||
|
||||
Reference in New Issue
Block a user