Permalink
Browse files

Added comments, updated pom.xml, updated README

  • Loading branch information...
christian-posta committed Aug 25, 2011
1 parent e6d3f95 commit 812264f8e4b705f21742285cc3a21bca21385edc
View
@@ -1 +1,8 @@
-Modeling a card-playing session in Java
+Modeling a card-playing session in Java using Apache Camel as the integration framework.
+
+To run, please make sure Maven is installed.
+
+The command line to run this solution is as follows:
+
+
+user@computer$ mvn camel:run
View
@@ -8,6 +8,13 @@
<artifactId>deck-of-cards</artifactId>
<version>1.0</version>
+ <name>Camel Deals Cards</name>
+ <description>
+ An example solution for reading a set of names from a file (that represent players) and
+ dealing cards to them. The dealt cards will be stored in XML
+ </description>
+
+
<dependencies>
<dependency>
<groupId>log4j</groupId>
@@ -6,28 +6,38 @@
import java.util.List;
/**
- * Created by IntelliJ IDEA.
- * User: ceposta
- * Date: 8/24/11
- * Time: 11:47 AM
- * To change this template use File | Settings | File Templates.
+ * Main abstraction for 'dealing' cards to players
*/
public class Dealer {
public static final int DEFAULT_NUM_CARDS_TO_DEAL = 5;
private CardShoe shoe;
private int numCardsToDeal;
+ /**
+ * Create a dealer with a default number of decks with the default
+ * shuffle algorithm
+ */
public Dealer() {
this(CardShoe.createShoeWithDefaultCards());
}
+ /**
+ * Allows more control over how the card shuffling happens, how many card decks, etc.
+ * @param shoe
+ */
public Dealer(CardShoe shoe) {
this.shoe = shoe;
this.shoe.shuffle();
this.numCardsToDeal = DEFAULT_NUM_CARDS_TO_DEAL;
}
+ /**
+ * Deals cards to a list of players. The number of cards that are dealt can be specified
+ * by the numCardsToDeal property
+ *
+ * @param players list of players to which cards will be dealt
+ */
public void dealCardsToPlayers(List<Player> players) {
int numberOfDealRounds = 0;
@@ -8,9 +8,21 @@
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <!--
+ Set the properties on the dealer, one of which can be the Shoe from which to deal cards.
+ Note, by injecting the shoe (optional), you can control how many decks of cards are involved,
+ the shuffling strategy, etc. See CardShoe.java for more info.
+ -->
+ <bean id="dealer" class="com.christianposta.fuse.Dealer">
+ <property name="numCardsToDeal" value="5" />
+ </bean>
+
+
+ <!-- This is where the routing definitions are written, in the camel DSL language (java) -->
<bean id="routingBean" class="com.christianposta.fuse.integration.CardRoutingDefinition" />
- <bean id="dealer" class="com.christianposta.fuse.Dealer" />
+ <!-- Instantiate the context for the camel container -->
<camel:camelContext>
<camel:routeBuilder ref="routingBean" />
</camel:camelContext>
@@ -22,7 +22,7 @@
* Time: 8:53 AM
* To change this template use File | Settings | File Templates.
*/
-public class DealCardsTest extends CamelSpringTestSupport{
+public class DealCardsCamelTest extends CamelSpringTestSupport{
@Override
protected AbstractApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("/spring/deal-cards-context.xml");

0 comments on commit 812264f

Please sign in to comment.