rendered paste body//Entity.h
#ifndef __ENTITY_H
#define __ENTITY_H
#include <iostream>
class Entity {
public:
Entity(std::string const &_Name);
~Entity();
std::string GetName();
int SetName(std::string const &_Name);
protected:
std::string Name;
static int ID;
private:
int IDCount = 0;
};
// ID counter and ID for each entity;
#endif
// entity.cpp
#include <iostream>
#include "Entity.h"
using namespace std;
Entity::Entity(std::string const &_Name) {
this->SetName(_Name);
ID = IDCount;
++IDCount;
}
Entity::~Entity() { }
std::string Entity::GetName() {
return Name;
}
int Entity::SetName(std::string const &_Name) {
if(_Name.length > 0 && _Name.length < 50) {
Name = _Name;
return 0;
} else {
return -1; // Name is too long
}
}