Last active
July 28, 2021 19:18
-
-
Save maneeshaindrachapa/3bd99c9459e0bd083cb8b869b1f059ae to your computer and use it in GitHub Desktop.
org.wso2.carbon.game.producer.GameProducerImpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.wso2.carbon.game.producer; | |
import org.wso2.carbon.game.producer.model.Champion; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.logging.Logger; | |
public class GameProducerImpl implements GameProducer { | |
private static final Logger LOGGER = Logger.getLogger(GameProducerImpl.class.getName()); | |
private static volatile GameProducerImpl gameProducer; | |
private static List<Champion> champions = new ArrayList<Champion>(); | |
private GameProducerImpl() { | |
} | |
// Use singleton design pattern to create single instance. | |
public static GameProducerImpl getInstance() { | |
if (gameProducer == null) { | |
synchronized (GameProducerImpl.class) { | |
if (gameProducer == null) { | |
gameProducer = new GameProducerImpl(); | |
} | |
} | |
} | |
return gameProducer; | |
} | |
public void createChampion(String championName) { | |
Champion champion = new Champion(championName); | |
LOGGER.info("Created a Champion:" + champion.getChampionName()); | |
} | |
public List<Champion> listChampions() { | |
return champions; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment