From the course: Object-Oriented Programming with C++

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Challenge: RPG character system

Challenge: RPG character system - C++ Tutorial

From the course: Object-Oriented Programming with C++

Challenge: RPG character system

(bright upbeat music) - [Instructor] In this module, you've learned about inheritance, method overriding, and composition. Now, let's put these concepts into practice with a simple RPG character system. You'll find the starter project in the courses GitHub repository under chapter three, 03_07, end folder. Let's look at what we've got here. First, we have a base character class with a constructor two public methods attack and display stats, a couple of protected member variables, name and health, and a static constant showing how much damage the character can do. The implementation is straightforward. The constructor uses an initializer list to set up the member variables and the attack and display text methods emit log messages to the console. We also have an equipment class to manage inventory. The public methods can be used to add items to the inventory and see what equipment we currently have. The private inventory member is a vector used to store inventory items. The…

Contents