#include <iostream>
#include <string>
using namespace std;
class Character {
private:
string nickname;
int level;
int exp;
public:
Character(string nickname, int level = 1,int exp = 0){
this -> nickname = nickname;
this -> level = level;
this -> exp = exp;
}
void gain_exp(int amount){
exp += amount;
while(exp >= 100){
level += 1;
exp -= 100;
}
}
void status(){
cout << "현재 레벨: " << level << "현재 경험치: "<< exp << endl;
}
};
int main(){
Character game("캐릭터1");
game.status();
game.gain_exp(250);
game.status();
}
To embed this project on your website, copy the following code and paste it into your website's HTML: