cout << "---------------------------------------------------\n";
cout << "# Level:" << getLevel() << " #\n";
cout << "# Max Hp:" << getMaxHp() << " #\n";
cout << "# Hp:" << getHp() << " #\n";
cout << "# Attack Point:" << getAtkPoint() << " #\n";
cout << "# Defense:" << getDefense() << " #\n";
cout << "---------------------------------------------------\n";
I wanted to do something like this but when number of digit of return value is more than 1 there will be a unwanted space
int sBasamak(int b)
{
int a=0;
while(b > 0)
{
a++;
b /= 10;
}
return a;
}
This is what I did for keeping number of digits but the other part of solution is beyond my wisdom, hope you understand what I want to try.
EDIT:(IF ANYONE WONDER HERE HOW I FIXED IT)
void space(int b,char gelen[])
{
int a=0;
while(b >0) {
a++;
b /= 10;
}
int c=0;
for(int i=0 ; gelen[i] ; i++)
{
c++;
}
cout << setw(51-c-a) << "#\n";
}
and
int a=getLevel();
int b=getMaxHp();
int c=getHp();
int d=getAtkPoint();
int e=getDefense();
cout << "---------------------------------------------------\n";
cout << "# Level:" << a ; space(a," Level:");
cout << "# Max Hp:" << b; space(b," Max Hp:");
cout << "# Hp:" << c; space(c," Hp:");
cout << "# Attack Point:" << d; space(d," Attack Point:");
cout << "# Defense:" << e; space(e," Defense:");
cout << "---------------------------------------------------\n";