* #496 Add pipeline module to parent pom ✨ * #496: Add main application class and test for pipeline * #496: Checkstyle format and add log messages on pipeline stages 🎨 * #496: Fill readme sections of pipeline ✨ * #496: Javadocs and checkstyle formatting 🎨 * #496: Follow PMD checks and add more explanation as block comment on App.java * #496: Apply requested PR changes by iluwatar 🎨 * #970: Replace log4j usage on commander pattern to Slf4j API 🎨 * #970: Replace log4j usage on dao pattern to Slf4j API 🎨 * #970: Replace log4j usage on data mapper pattern to Slf4j API 🎨 * #970: Remove log4j dependency on data transfer object pom 🔥 * #970: Replace log4j usage on module pattern to Slf4j API 🎨 * #970: Replace log4j usage on serverless pattern to Slf4j API 🎨 This also removes the aws log4j dependency * #970: Remove unnecessary gitignore line for log4j.xml 🔥 * #970: Remove remaining remnants of log4j 🔥 * #970: Replace System.out logging with appropriate logging methods 🎨 * #970: Replace System.out method references to Logger::info 🎨
This commit is contained in:
committed by
Ilkka Seppälä
parent
72b174619f
commit
cfdfedbd2e
@ -25,6 +25,8 @@ package com.iluwatar.typeobject;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**<p>Type object pattern is the pattern we use when the OOP concept of creating a base class and
|
||||
* inheriting from it just doesn't work for the case in hand. This happens when we either don't know
|
||||
@ -45,6 +47,7 @@ import org.json.simple.parser.ParseException;
|
||||
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
/**
|
||||
* Program entry point.
|
||||
* @param args command line args
|
||||
@ -62,9 +65,9 @@ public class App {
|
||||
CellPool pool = new CellPool(numOfRows * numOfRows + 5);
|
||||
CandyGame cg = new CandyGame(numOfRows, pool);
|
||||
if (round > 1) {
|
||||
System.out.println("Refreshing..");
|
||||
LOGGER.info("Refreshing..");
|
||||
} else {
|
||||
System.out.println("Starting game..");
|
||||
LOGGER.info("Starting game..");
|
||||
}
|
||||
cg.printGameStatus();
|
||||
end = System.currentTimeMillis();
|
||||
@ -72,13 +75,13 @@ public class App {
|
||||
pointsWon += cg.totalPoints;
|
||||
end = System.currentTimeMillis();
|
||||
}
|
||||
System.out.println("Game Over");
|
||||
LOGGER.info("Game Over");
|
||||
if (pointsWon >= toWin) {
|
||||
System.out.println(pointsWon);
|
||||
System.out.println("You win!!");
|
||||
LOGGER.info("" + pointsWon);
|
||||
LOGGER.info("You win!!");
|
||||
} else {
|
||||
System.out.println(pointsWon);
|
||||
System.out.println("Sorry, you lose!");
|
||||
LOGGER.info("" + pointsWon);
|
||||
LOGGER.info("Sorry, you lose!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ package com.iluwatar.typeobject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.iluwatar.typeobject.Candy.Type;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The CandyGame class contains the rules for the continuation of the game and has
|
||||
@ -31,6 +33,9 @@ import com.iluwatar.typeobject.Candy.Type;
|
||||
*/
|
||||
|
||||
public class CandyGame {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CandyGame.class);
|
||||
|
||||
Cell[][] cells;
|
||||
CellPool pool;
|
||||
int totalPoints;
|
||||
@ -57,21 +62,21 @@ public class CandyGame {
|
||||
}
|
||||
|
||||
void printGameStatus() {
|
||||
System.out.println("");
|
||||
LOGGER.info("");
|
||||
for (int i = 0; i < cells.length; i++) {
|
||||
for (int j = 0; j < cells.length; j++) {
|
||||
String candyName = cells[i][j].candy.name;
|
||||
if (candyName.length() < 20) {
|
||||
int totalSpaces = 20 - candyName.length();
|
||||
System.out.print(numOfSpaces(totalSpaces / 2) + cells[i][j].candy.name
|
||||
LOGGER.info(numOfSpaces(totalSpaces / 2) + cells[i][j].candy.name
|
||||
+ numOfSpaces(totalSpaces - totalSpaces / 2) + "|");
|
||||
} else {
|
||||
System.out.print(candyName + "|");
|
||||
LOGGER.info(candyName + "|");
|
||||
}
|
||||
}
|
||||
System.out.println("");
|
||||
LOGGER.info("");
|
||||
}
|
||||
System.out.println("");
|
||||
LOGGER.info("");
|
||||
}
|
||||
|
||||
ArrayList<Cell> adjacentCells(int yIndex, int xIndex) {
|
||||
@ -121,7 +126,7 @@ public class CandyGame {
|
||||
}
|
||||
|
||||
void handleChange(int points) {
|
||||
System.out.println("+" + points + " points!");
|
||||
LOGGER.info("+" + points + " points!");
|
||||
this.totalPoints += points;
|
||||
printGameStatus();
|
||||
}
|
||||
|
Reference in New Issue
Block a user