Command line card game played by computer
Developed by Joachim Tan & Keane Nugroho.
Explore the docs »
Report Bug
Table of Contents
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
- Clone the repo
git clone https://github.com/joachimstanislaus/Java_Card_Game_V1.git
- Open terminal/command prompt in the directory where cards.jar is saved
- Run this command to compile:
javac -cp .:cards.jar src/CardGame.java
- Run this command every time you want to run:
java -cp .:cards.jar CardGame
- Type the number of players and ENTER (if you want to use the test pack of cards, type 2)
- Type the filename of the pack of cards (samplepack.txt will work)
- To extract contents inside the jar
jar -xvf cards.jar
To run the game, run the main method of the CardGame
class. You will be prompted to enter the number of players. If you want to use the test pack of cards, enter 2 for number of players. When asked for the filename of the pack of cards, enter samplepack.txt
. The game should ensue, and a winner established. Players will output their turns to seperate files under the log
directory, along with the final state of each card deck.
- In command prompt, navigate to the root folder of the project (automated-java-card-game)
- Run the command
javac -cp src;lib/junit-4.13 src/CardGame.java
- Run the command
java -cp src;lib/junit-4.13 src/CardGame.java
- Type the number of players and ENTER (if you want to use the test pack of cards, type 22)
- Type the filename of the pack of cards (testPack.txt will work)
To run the full test suite, compile the test
folder and then run the CardGameTestSuite
class. This will automatically run the individual test files for each class.
- The tests must be run from the
test
directory. To switch to it from the root folder, use:
cd test
- Compile the source code to bytecode
javac -cp .;../lib/junit-4.13.2.jar CardGameTestSuite.java
- Run the tests with JUnit
java -cp .;../lib/junit-4.13.2.jar;../lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore CardGameTestSuite
The expected output is:
JUnit version 4.13.2
.........Player 1 has won the game
.Player 4 has won the game
.....
Time: 0.86
OK (15 tests)
The user can specify the number of players, n.
Each player picks up and discards a card on their turn.
Players are numbered from 1 to n.
A player will keep cards that equal their player number.
If a player gets 4 of the same card, they win the game.
Players output their moves to text file in the folder log
Distributed under the MIT License. See LICENSE.txt
for more information.
Project Link: https://github.com/joachimstanislaus/Java_Card_Game_V1