From 30facca41d447d984fd6642ca16f7278d54d2bec Mon Sep 17 00:00:00 2001 From: Patricia Aas Date: Tue, 5 Oct 2021 10:15:47 +0200 Subject: [PATCH] Split off the create class into it's own exercise --- .../15/build_files/15-compilation-linking.md | 25 ++++++++----------- exercises/17/classes/17-create-class.md | 5 ++++ 2 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 exercises/17/classes/17-create-class.md diff --git a/exercises/15/build_files/15-compilation-linking.md b/exercises/15/build_files/15-compilation-linking.md index 28eadbc..9c175c6 100644 --- a/exercises/15/build_files/15-compilation-linking.md +++ b/exercises/15/build_files/15-compilation-linking.md @@ -5,7 +5,8 @@ In this exercise we will add a couple of files to the project. ## CMake As described in the slides, the project is defined by several CMake files. The ones we are interested -is `CMakeLists.txt` in the root project folder and the `CMakeLists.txt` file in the `lib` folder. +is [`CMakeLists.txt`](../../../CMakeLists.txt) in the root project folder and +the [`CMakeLists.txt`](../../../lib/CMakeLists.txt) file in the `lib` folder. You can see that the root CMake file is adding the `lib` subdirectory, this means that it is looking for a `CMakeLists.txt` file within that folder. @@ -16,24 +17,20 @@ The CMake file in the `lib` folder describes a few package requirements and then file(GLOB_RECURSE sources CONFIGURE_DEPENDS "*.cpp" "*.hpp") ``` -Here it is creating a variable called `sources` that will contain all `.cpp` and `.hpp` files within the `lib` folder. -This means that if we want to add new files, we don't have to list them here, as any applicable files are included. But -adding a file will not automatically add the file in the IDE, as CMake needs to be run again for those changes to apply. - -This is because the current configuration and list of files are defined in the CMake and IDE project files inside of -your build folder. +Here it is creating a CMake variable called `sources` that will contain all `.cpp` and `.hpp` files within the `lib` +folder. This means that if we want to add new files, we don't have to list them here, as any applicable files are +included. But adding a file will not automatically add the file in the IDE, as CMake needs to be run again for those +changes to apply. # Exercise -One of the Pac-Man ghosts is missing. We will fully implement this ghost later but for now lets add the `.cpp` +One of the Pac-Man ghosts is missing. We will fully implement this ghost later but for now let's add the `.cpp` and `.hpp` files to the project. -1. Create `Clyde.hpp` and `Clyde.cpp` files within the `lib` folder. +1. Create a `Clyde.hpp` in the `lib/include` folder and a `Clyde.cpp` file in the `lib` folder. -2. Run CMake again and see your IDE update to include this new file. You can try compiling again and see what happens. +2. Run CMake again and see your IDE update to include these new files. You can try compiling again and see what happens. -3. Include the `Clyde.hpp` file within the `Clyde.cpp` file. +3. Include the `Clyde.hpp` file within the `Clyde.cpp` file, and add `#pragma once` to `Clyde.hpp`. -4. Create an empty class named `Clyde` within the `.hpp` file. Look at other ghost `.hpp` files and see how they define - the class. It does not need to inherit from the `Ghost` base class and it does not need any functions. But if you - have extra time, try to inherit from the Ghost class and see what happens when you try to compile. +4. Include `Clyde.hpp` in [GameState.hpp](../../../lib/include/GameState.hpp) and rebuild diff --git a/exercises/17/classes/17-create-class.md b/exercises/17/classes/17-create-class.md new file mode 100644 index 0000000..f524a0a --- /dev/null +++ b/exercises/17/classes/17-create-class.md @@ -0,0 +1,5 @@ + + +4. Create an empty class named `Clyde` within the `.hpp` file. Look at other ghost `.hpp` files and see how they define + the class. It does not need to inherit from the `Ghost` base class and it does not need any functions. But if you + have extra time, try to inherit from the Ghost class and see what happens when you try to compile.