Assignment Chef icon Assignment Chef
All English tutorials

Programming lesson

Profémon Project Tutorial: Mastering C++ Classes and Enums with a Pokémon-Inspired Assignment

A step-by-step tutorial for CSCI 135 Project 2: Profémon! Learn to design Skill and Profemon classes, use enums, and organize header/source files with a fun Pokémon analogy.

C++ classes tutorial C++ enum example CSCI 135 project 2 Profémon assignment C++ header and source files object-oriented programming C++ Skill class C++ Profemon class Specialty enum ML SOFTWARE HARDWARE C++ programming assignment help Pokémon style C++ project learn C++ with games C++ OOP for beginners C++ vector skills C++ include guards C++ getters and setters

Introduction: Catching C++ Classes with Profémon

In the CSCI 135 Project 2, you're tasked with building a Profémon system — a Pokémon-inspired game where creatures have skills and specialties. This tutorial will guide you through defining the Skill and Profemon classes, using enums, and splitting code into header and source files. By the end, you'll have a solid grasp of C++ object-oriented programming (OOP) fundamentals.

Think of this like building your own Pokémon trainer app. Just as trainers choose Pokémon with unique abilities, you'll create Profemon with specialties like ML (machine learning), SOFTWARE, and HARDWARE. This mirrors real-world tech trends — imagine an AI app where each Profemon excels in a different domain.

Understanding the Assignment Structure

The project requires four files: skill.hpp, skill.cpp, profemon.hpp, and profemon.cpp. You'll also submit a main.cpp for testing. Let's break down each component.

Skill Class: The Building Block

The Skill class stores information about a Profemon's move. In your private members, you'll have:

  • name (string) — the skill's name, like "Thunderbolt"
  • description (string) — what it does
  • power (int) — damage or effect strength

Public methods include a default constructor, a parameterized constructor, and getters/setters. Here's a minimal header example:

// skill.hpp
#ifndef SKILL_HPP
#define SKILL_HPP
#include <string>

class Skill {
private:
    std::string name;
    std::string description;
    int power;
public:
    Skill();
    Skill(std::string name, std::string description, int power);
    std::string getName();
    void setName(std::string name);
    // ... other getters/setters
};
#endif

Implement these in skill.cpp. Remember to include the header and use the scope resolution operator.

Profemon Class: The Main Creature

Before the Profemon class, define an enum called Specialty with values ML, SOFTWARE, and HARDWARE. Enums are perfect for fixed sets of options — like choosing a character class in a game.

// profemon.hpp
enum Specialty { ML, SOFTWARE, HARDWARE };

The Profemon class has private members:

  • name (string)
  • level (int)
  • specialty (Specialty)
  • skills (array or vector of Skill objects, max 3)

Public methods include constructors, getters, setters, and a function to add skills. For example, you might have a learnSkill method that replaces the oldest skill if the Profemon already knows three.

Step-by-Step Implementation Guide

1. Set Up Your Files

Create the four files in your project directory. Use include guards in headers to prevent double inclusion.

2. Implement the Skill Class

In skill.cpp, implement all methods. Test with a simple main that creates a Skill object and prints its details.

3. Define the Specialty Enum and Profemon Class

In profemon.hpp, place the enum before the class. For the skills, consider using std::vector<Skill> for dynamic storage, or a fixed array of size 3.

4. Implement Profemon Methods

In profemon.cpp, implement constructors, getters, setters, and the skill management function. Ensure you handle edge cases like adding a skill when the vector is full.

5. Compile and Test Locally

Use a command like:

g++ -std=c++11 -Wall skill.cpp profemon.cpp main.cpp -o profemon

Run your program and verify all functions work. For example, create a Profemon with specialty ML, teach it three skills, and print its info.

Common Pitfalls and Tips

  • Missing include guards — Always use #ifndef/#define/#endif.
  • Enum scope — The enum is global, but you can use it inside the class. Avoid naming conflicts.
  • Memory management — If you use raw arrays, watch out for buffer overflows. Vectors are safer.
  • Testing — Write test cases for every method, especially constructors and skill addition.

Connecting to Real-World Trends

Just as AI apps like ChatGPT use specialized models for different tasks, your Profemon have specialties: ML for data, SOFTWARE for code, HARDWARE for systems. This assignment mirrors how modern software is built with modular classes — each component has a clear purpose. In the world of gaming, think of character classes in RPGs; your enum defines the Profemon's role.

Complete Example (Partial)

Here's a snippet of a working main.cpp:

#include <iostream>
#include "skill.hpp"
#include "profemon.hpp"

int main() {
    Skill thunder("Thunderbolt", "Electric shock", 50);
    Profemon pikachu("Pikachu", 5, ML);
    pikachu.learnSkill(thunder);
    std::cout << pikachu.getName() << " learned " << thunder.getName() << std::endl;
    return 0;
}

Compile and run to verify. Expand to test all methods.

Conclusion

By completing this tutorial, you've built a solid foundation in C++ classes, enums, and file organization. The Profémon project is a fun way to learn OOP — much like designing your own Pokémon team. Keep experimenting and happy coding!