BraiiiiiiinnnzzzZ 🧠
- Introduction
- ex00. BraiiiiiiinnnzzzZ
- ex01. Moar brainz!
- ex02. HI THIS IS BRAIN
- ex03. Unnecessary violence
- ex04. Sed is for losers
- ex05. Karen 2.0
- ex06. Karen-filter
- Installation
- Summary
This second set of exercises is a bit more interesting. We'll be learning the basics of memory allocation in C++, references, pointers, and a rough look at switches.
This first exercise asks us to simply create a bunch of classes with basic methods we will use in future exercises in the module. We must have two ways of allocating instances of the class: either on the stack or on the heap, and free the allocated space at the right time.
This is an example output given my main.
This second exercise consists of creating a method that will summon N zombies in one go, without naming each one of them. Then they all announce themselves and are properly destroyed.
This next exercise is super simple, it only aims to differentiate between pointers and references
This one extends the concepts of references and pointers from the previous exercise, creating two types of humans in two classes that can attack each other with different weapons.
This exercise aims to replicate the basic performance of the sed command (stream editor), receiving a file and a string to replace with another. It saves the output to a file with the same name ending in .replace. This exercise helps us understand file streams and strings in C++.
Note: the example above shows how the replace operation is reversible (unsurprisingly).
The next two exercises expand on the idea of refernces a bit further. We create a Karen class that can give various messages of types DEBUG, INFO, WARNING and ERROR. We are asked to create that outputs the proper message depending message type.
This last exercise is an extension of the previous one. However this time we receive the message type from the user and output that type's message and all the message types above it (order is DEBUG < INFO < WARNING < ERROR). We must coordinate the responses using switches for this exercise.
Note how the DEBUG message is not shown because it is below INFO.
For this project and fututre C++ projects it is only required to have clang
and/or gcc
, which provide their respective compilers clang++
and g++
. It is also recommended to install the valgrind
package on Linux for debugging purposes. Every exercise (unless specified otherwise) includes its own Makefile with the necessary instructions. In some cases certain tweaks needed to be made to ensure the most similar results in both Linux and MacOS.
This one was definitely harder than the previous one, but it was still pretty fun.
June 13th, 2022