#include <iostream>
#include <string>
using namespace std;
class Player {
public:
string name;
int level;
int exp;
Player(string n) : name(n), level(1), exp(0) {}
void gain_exp(int amount) {
exp += amount;
if (exp >= 100) {
level += 1;
exp = 0;
}
}
};
int main() {
Player p("Hero");
p.gain_exp(120);
cout << p.level << endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: