A simple game of Battleship, written in C++. The purpose of this repository is to serve as an entry point into coding exercises and it was especially created for scrum.orgs Applying Professional Scrum for Software Development course (www.scrum.org/apssd). The code in this repository is unfinished by design.
This code can be compiled by using MAKE or CMAKE. It has been tested on Ubuntu 20.04 and Debian GNU/Linux 10
The recommended way to develop, build and test the application is by using DevContainers. DevContainers are a feature of Visual Studio Code that allow you to define a development environment in a Docker container. This ensures that all developers have the same development environment and dependencies.
To use DevContainers, you need to have Visual Studio Code installed. You can download it from https://code.visualstudio.com/ And you need to have Docker installed. You can download it from https://www.docker.com/
- Clone the repository
- Open Visual Studio Code
- Click on the "Open Folder" button
- Select the folder where you cloned the repository
- Click on the "Reopen in Container" button in the bottom right corner or on the small blue area on the left bottom corner and then select "Reopen in Container from the drop-down on the top".
Now you are running your development environment in a Docker container. The first time you open the project in a DevContainer, it will take a few minutes to build the container. After that, the container will be reused and the startup time will be much faster.
All settings in Visual Studio Code are stored in the .devcontainer and .vscode folder and should get you started with the development quickly.
- To build and run the application, you can just press <Ctrl>+<Shift>+<B>.
- To debug the application, you can press F5.
- To run the tests you can press <Ctrl>+<Shift>+<T>.
VSCode also features an TextExplorer UI. The DevContainer has all necessary extensions installed. You can run test and see the results in the sidebar.
If you have a local development environment using gcc, you can build and run the application using either CMAKE or MAKE
cd build
cmake --build .
./Battleship
cd MAKE
make
./Battleship.exe
Alternatively, you can run the application using a Docker Container directly. The repository contains a dockerfile that should work for most scenarios.
cd battleship-cpp
docker build . -t battleship
docker run -it -v ${PWD}:/battleship battleship bash
Then you can use the commands from above to build and execute the application.
You can run Unit-Tests on the console. They are created using Google Tests (https://github.com/google/googletest). You need to install Google Tests to build and run the unit test.
sudo apt update
sudo apt install libgtest-dev
brew install googletest
- Install vcpkg.
- Install Google Tests
vcpkg install gtest
cd build
cmake --build .
ctest -V
cd MAKE
make TestRunner
./TestRunner