This project, C++ Module 01, focuses on dynamic memory allocation, pointers, and object relationships. You will implement a Zombie class, create a horde of zombies, manage strings, and develop a complaint system using function pointers and switch statements. These exercises provide a solid foundation in C++ programming concepts and practices.
Objectives 🚀:
- This exercise will introduce you to dynamic memory allocation and pointer manipulation in C++.
- You will be creating a class that represents a zombie. Requirement:
- Create a
Zombie
class. Each zombie will have a name. - Implement a member function named
announce()
that will print the following message:<name>: BraiiiiiiinnnzzzZ...
. - The name of the zombie should be passed to the constructor.
- Create a function named
newZombie()
which takes a string representing a name and returns a pointer to a new zombie. - Create a function named
randomChump()
that creates a zombie, assigns it a random name, and immediately announces it. - Your main function should create several zombies (both on the stack and on the heap) and have them announce themselves.
Objectives 🚀:
- This exercise builds on the previous one by exploring the behavior of destructors.
- You will create and destroy zombies dynamically. Requirements:
- Add a destructor to your
Zombie
class that prints the message:<name> is destroyed
. - In your main function, dynamically allocate several zombies, have them announce themselves, and then properly destroy them to ensure there are no memory leaks.
Objectives 🚀:
- This exercise introduces the
Weapon
class and explores how objects can be passed around by reference. Requirements: - Create a
Weapon
class that has atype
attribute and agetType()
method that returns the type. - Create a
setType()
method that modifies the weapon type. - Create a
HumanA
class that takes a reference to aWeapon
in its constructor and has anattack()
method that prints a message containing the human's name and the weapon type. - Create a
HumanB
class that is similar toHumanA
but allows the weapon to be set later on using a method.
Objectives 🚀:
- This exercise introduces basic file input/output (I/O) and string manipulation in C++. Requirements:
- Write a program that takes a filename and two strings as parameters.
- The program should open the file, replace all occurrences of the first string with the second string, and write the results to a new file.
Objectives 🚀:
- This exercise explores the
switch
statement and organizing code with different levels of verbosity. Requirements: - Create a
Harl
class with four member functions:debug()
,info()
,warning()
, anderror()
. - Implement a
complain()
function that calls one of the four methods based on the input string passed to it. - Use a
switch
statement to choose which method to call.
Objectives 🚀:
- This exercise builds on the previous one by introducing filters. Requirements:
- Modify the
Harl
class to print only messages at or above a certain severity level. The severity levels aredebug
,info
,warning
, anderror
. - Implement this filtering logic so that Harl only complains at the specified level or higher.