Skip to content
Permalink
Browse files
add guides
  • Loading branch information
ac0745 committed Jan 19, 2022
1 parent 106d9bb commit e572cca6b443d3acee01fc17e5db5139190b3ced
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 0 deletions.
@@ -0,0 +1,86 @@
[
{
"type": "test",
"taskId": "test-2677297096",
"source": {
"name": "byhand",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_byhand",
"arePartialPointsAllowed": false,
"timeoutSeconds": 40,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": []
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
},
{
"type": "test",
"taskId": "test-356226860",
"source": {
"name": "cmake",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_main",
"arePartialPointsAllowed": false,
"timeoutSeconds": 40,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": []
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
},
{
"type": "test",
"taskId": "test-2118214315",
"source": {
"name": "Editing CMake",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_validate",
"arePartialPointsAllowed": false,
"timeoutSeconds": 40,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": []
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
}
]
@@ -0,0 +1,35 @@
{
"name": "4003CEM-compiling",
"children": [
{
"title": "Compilation",
"id": "15cfe5df-ef58-7a49-4cbb-2e2b388c20e4",
"pageId": "15cfe5df-ef58-7a49-4cbb-2e2b388c20e4",
"type": "page"
},
{
"id": "a5612fd7-685d-5f26-c893-5e36cf7761f9",
"title": "Build systems",
"pageId": "6d214a60-4463-9a03-df24-6e2713646210",
"type": "page"
},
{
"title": "CMake",
"id": "7c240bda-fc48-98ba-9f13-8e2f99f87d6d",
"pageId": "7c240bda-fc48-98ba-9f13-8e2f99f87d6d",
"type": "page"
},
{
"id": "33d10dfe-b9f5-35ff-a83b-44b2bb525262",
"title": "Your go",
"pageId": "2708a977-b3d9-574d-3e61-51c2be88e9da",
"type": "page"
},
{
"id": "a6efb014-e460-6f09-ca91-1fe5bb34c719",
"title": "Advanced",
"pageId": "e96daf37-45d0-1a21-d7b9-dcd2f7718600",
"type": "page"
}
]
}
@@ -0,0 +1,8 @@

<h2 style="color:red">Further learning</h2>
If you want to investigate cmake further, the official tutorial is available here:
https://cmake.org/cmake-tutorial/
However there are a large number of more beginner friendly blogs and videos available online that you might find a better option.

CMake is not the only automated tool that you can use to make your life easier. Doxygen for example (https://caiorss.github.io/C-Cpp-Notes/Doxygen-documentation.html) can be used to automatically convert docstrings and comments in your code into documentation in multiple formats (html, pdf).
At the very least, writing your docstrings in doxygen format ensures that they will be clear and understandable even if you don't generate a documentation document from it.
@@ -0,0 +1,20 @@
Although an important skill, compiling everything manually is obviously very inconvenient.
There are multiple steps that must be remembered and performed in the correct order.

Especially as we start to create larger and larger projects, the number of files can easily become unmanageable.
For example, the OpenCV computer vision library, the most widely used vision library contains almost 800 header (.h) files and more than 3000 source (.c and .cpp) files. Manually compiling it is obviously going to be a problem.

For that reason, everything except the smallest of C++ projects normally makes use of build systems and so called "make files".
Build systems are tools that run a serious of instructions (in the make file) to compile and build all the different parts of a C++ project.

Build systems can be used with multiple languages but we are concerns specifically with C++ on 4003CEM.

One of the more widely used build systems is CMake.
It has a number of advantages including being cross platform so that it is available on all operating systems.

<h2 style="color:darkorange">Compiling with cmake</h2>
Compile the **main.cpp** file into an executable using the supplied cmake project file.
The project file has been set up and already contains all the commands needed to produce and executable called **main**.
This should be all the information you need to compile the executable.

{Check It!|assessment}(test-356226860)
@@ -0,0 +1,10 @@
Having demonstrated that you are able to use CMake to build a project, it is time to edit and existing project in order to add new functionality.

<h2 style="color:darkorange">Editing cmake</h2>
The files **passwords.h**, **passwords.cpp** and **validate.cpp** have been provided for you.
**passwords.h** and **passwords.cpp** contain a pair of functions, **validate.cpp** contains a `main()` that uses those functions.
Edit your CMakeLists.txt file to compile **validate.cpp** into an executable program called **validate**.
**passwords.h** and **.cpp** should be treated as a library that is used by **validate**.

{Check It!|assessment}(test-2118214315)

@@ -0,0 +1,20 @@
Demonstrate that we can compile programs by hand.

Being able to compile code manually is important as it demonstrates that you understand what the process is, the steps that go into creating an executable and how the various files interact.

Without this knowledge you will find it difficult to solve compiler issues in the future when you are using IDEs or build systems instead of manually compiling as you will not know what is supposed to be happening and so will not be able to identify which part has gone wrong.


<h2 style="color:green">Compiling by hand</h2>
Compile the **main.cpp** file into an executable called **byhand** using the 3 separate compile commands needed. Details are in the lecture slides.

1) We need to compile the **main.cpp** file
2) Because our program uses the code in the print_two .h and .cpp files we also need to compile **print_two.cpp.**
- **print_two.h** is automatically included thanks to the `#include` lines in our code.
3) Finally we need to link together those two object files to produce the final executable file that we are going to call **byhand**.

This executable should be placed in the bin/ directory.

{Check It!|assessment}(test-2677297096)


@@ -0,0 +1,10 @@
<h2 style="color:darkorange">Your project</h2>
Using what we have learnt in the previous weeks, create a simple game that plays rock, paper, sissors.

Each round the game should ask the user for input and also generate a random move for the computer. The user input and computer move can then be compared to see who has wrong.
Once a player has won 3 rounds they are declared the winner.

Think carefully about how you are going to structure your code with regards to .h and .cpp files.

Think carefully about what control structures you are going to use in your functions, e.g. for loops and while loops.

@@ -0,0 +1,89 @@
{
"sections": [
{
"id": "15cfe5df-ef58-7a49-4cbb-2e2b388c20e4",
"title": "Compilation",
"files": [
{
"path": "#terminal: ",
"panel": 1,
"action": "open"
}
],
"layout": "3-cell-tree",
"path": [],
"type": "markdown",
"content-file": ".guides/content/Compilation-15cf.md",
"chapter": false,
"reset": [],
"teacherOnly": false,
"closeTerminalSession": true,
"learningObjectives": ""
},
{
"id": "6d214a60-4463-9a03-df24-6e2713646210",
"title": "Build systems",
"files": [],
"path": [],
"type": "markdown",
"content-file": ".guides/content/Build-systems-6d21.md",
"chapter": false,
"reset": [],
"teacherOnly": false,
"closeTerminalSession": true,
"learningObjectives": ""
},
{
"id": "7c240bda-fc48-98ba-9f13-8e2f99f87d6d",
"title": "CMake",
"files": [],
"layout": "",
"path": [],
"type": "markdown",
"content-file": ".guides/content/CMake-7c24.md",
"chapter": false,
"reset": [],
"teacherOnly": false,
"closeTerminalSession": true,
"learningObjectives": ""
},
{
"id": "2708a977-b3d9-574d-3e61-51c2be88e9da",
"title": "Your go",
"files": [],
"path": [],
"type": "markdown",
"content-file": ".guides/content/Your-go-2708.md",
"chapter": false,
"reset": [],
"teacherOnly": false,
"closeTerminalSession": true,
"learningObjectives": ""
},
{
"id": "e96daf37-45d0-1a21-d7b9-dcd2f7718600",
"title": "Advanced",
"files": [],
"path": [],
"type": "markdown",
"content-file": ".guides/content/Advanced-e96d.md",
"chapter": false,
"reset": [],
"teacherOnly": false,
"closeTerminalSession": true,
"learningObjectives": ""
}
],
"theme": "light",
"scripts": [],
"lexikonTopic": "",
"suppressPageNumbering": false,
"useSubmitButtons": true,
"useMarkAsComplete": true,
"hideMenu": false,
"allowGuideClose": false,
"collapsedOnStart": false,
"hideSectionsToggle": false,
"hideBackToDashboard": false,
"protectLayout": false
}

0 comments on commit e572cca

Please sign in to comment.