Skip to content

Commit

Permalink
Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioaniche authored and casperboone committed Apr 20, 2019
1 parent 9f37e03 commit cfd49dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
package nl.tudelft.jpacman.npc.ghost;

import static org.mockito.Mockito.mock;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import com.google.common.collect.Lists;
import nl.tudelft.jpacman.board.Board;
import nl.tudelft.jpacman.board.BoardFactory;
import nl.tudelft.jpacman.board.Direction;
Expand All @@ -19,11 +12,16 @@
import nl.tudelft.jpacman.npc.Ghost;
import nl.tudelft.jpacman.points.PointCalculator;
import nl.tudelft.jpacman.sprite.PacManSprites;

import com.google.common.collect.Lists;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

/**
* Tests the various methods provided by the {@link Navigation} class.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public class PointCalculatorLoader {
public PointCalculator load() {

try {
if(clazz==null)
if (clazz == null) {
clazz = loadClassFromFile();
}

return (PointCalculator) clazz.newInstance();
} catch (Exception e) {
Expand All @@ -33,22 +34,22 @@ public PointCalculator load() {
return null;
}

@SuppressWarnings({"PMD.AvoidPrintStackTrace", "PMD.SystemPrintln"})
private Class loadClassFromFile() {

Properties prop = new Properties();
try {
prop.load(getClass().getClassLoader().getResourceAsStream("scorecalc.properties"));
String strategyToLoad = prop.getProperty("scorecalculator.name");

if(strategyToLoad.equals("DefaultPointCalculator"))
if ("DefaultPointCalculator".equals(strategyToLoad)) {
return DefaultPointCalculator.class;
}

return loadClass(strategyToLoad);
} catch (Exception e) {
e.printStackTrace();
System.err.println("Could not dinamically load the points calculator class. Something is really wrong with your JPacman. Ask a TA.");
System.exit(-1);
return null; // dead code
throw new RuntimeException("Could not dinamically load the points calculator.", e);
}
}

Expand Down

0 comments on commit cfd49dd

Please sign in to comment.