Contributors Forks Stargazers Issues MIT License LinkedIn


Java Card Game

Command line card game played by computer
Developed by Joachim Tan & Keane Nugroho.
Explore the docs »

Report Bug

Table of Contents
  1. About The Project
  2. Game Functionality
  3. Getting Started
  4. Running the game
  5. Testing
  6. License
  7. Contact

About The Project

Built With

  • Java

(back to top)

Getting Started

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.

Installation

  1. Clone the repo
    git clone https://github.com/joachimstanislaus/Java_Card_Game_V1.git

(back to top)

Running The Game

Run The Game From Jar Release

  1. Open terminal/command prompt in the directory where cards.jar is saved
  2. Run this command to compile:
javac -cp .:cards.jar src/CardGame.java
  1. Run this command every time you want to run:
java -cp .:cards.jar CardGame
  1. Type the number of players and ENTER (if you want to use the test pack of cards, type 2)
  2. Type the filename of the pack of cards (samplepack.txt will work)
  3. To extract contents inside the jar
jar -xvf cards.jar

(back to top)

Run The Game From Source Code

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.

(back to top)

Run The Game From Windows Command Line

  1. In command prompt, navigate to the root folder of the project (automated-java-card-game)
  2. Run the command javac -cp src;lib/junit-4.13 src/CardGame.java
  3. Run the command java -cp src;lib/junit-4.13 src/CardGame.java
  4. Type the number of players and ENTER (if you want to use the test pack of cards, type 22)
  5. Type the filename of the pack of cards (testPack.txt will work)

(back to top)

Testing

Run The Test From VS Code

(back to top)

Run The Test Suite

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.

(back to top)

Run The Test From Windows Command Line

  1. The tests must be run from the test directory. To switch to it from the root folder, use:
cd test
  1. Compile the source code to bytecode
javac -cp .;../lib/junit-4.13.2.jar CardGameTestSuite.java
  1. 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)

(back to top)

Game functionality

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

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Project Link: https://github.com/joachimstanislaus/Java_Card_Game_V1

(back to top)