#502 Replaced usages of System.out with logger.
This commit is contained in:
@ -23,6 +23,9 @@
|
||||
|
||||
package com.iluwatar.twin;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This class represents a Ball which extends {@link GameItem} and implements the logic for ball
|
||||
* item, like move and draw. It hold a reference of {@link BallThread} to delegate the suspend and
|
||||
@ -30,6 +33,8 @@ package com.iluwatar.twin;
|
||||
*/
|
||||
public class BallItem extends GameItem {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BallItem.class);
|
||||
|
||||
private boolean isSuspended;
|
||||
|
||||
private BallThread twin;
|
||||
@ -41,11 +46,11 @@ public class BallItem extends GameItem {
|
||||
@Override
|
||||
public void doDraw() {
|
||||
|
||||
System.out.println("doDraw");
|
||||
LOGGER.info("doDraw");
|
||||
}
|
||||
|
||||
public void move() {
|
||||
System.out.println("move");
|
||||
LOGGER.info("move");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,6 +23,9 @@
|
||||
|
||||
package com.iluwatar.twin;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This class is a UI thread for drawing the {@link BallItem}, and provide the method for suspend
|
||||
* and resume. It hold the reference of {@link BallItem} to delegate the draw task.
|
||||
@ -31,6 +34,8 @@ package com.iluwatar.twin;
|
||||
|
||||
public class BallThread extends Thread {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BallThread.class);
|
||||
|
||||
private BallItem twin;
|
||||
|
||||
private volatile boolean isSuspended;
|
||||
@ -61,12 +66,12 @@ public class BallThread extends Thread {
|
||||
|
||||
public void suspendMe() {
|
||||
isSuspended = true;
|
||||
System.out.println("Begin to suspend BallThread");
|
||||
LOGGER.info("Begin to suspend BallThread");
|
||||
}
|
||||
|
||||
public void resumeMe() {
|
||||
isSuspended = false;
|
||||
System.out.println("Begin to resume BallThread");
|
||||
LOGGER.info("Begin to resume BallThread");
|
||||
}
|
||||
|
||||
public void stopMe() {
|
||||
|
@ -24,16 +24,21 @@
|
||||
|
||||
package com.iluwatar.twin;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* GameItem is a common class which provides some common methods for game object.
|
||||
*/
|
||||
public abstract class GameItem {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GameItem.class);
|
||||
|
||||
/**
|
||||
* Template method, do some common logic before draw
|
||||
*/
|
||||
public void draw() {
|
||||
System.out.println("draw");
|
||||
LOGGER.info("draw");
|
||||
doDraw();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user