All pastes #635163 Raw Edit

Anonymous

public text v1 · immutable
#635163 ·published 2007-07-26 21:53 UTC
rendered paste body
#include <iostream.h>
#include "charInfo.h"
#include <string.h>
using std::string;


void charInfo::setName() //sets the players name
{   
    int SIZE = 100;
    char msg[SIZE];
	cout <<"+-So what is your characters name?               +"<< endl;
	cout <<"|                                                |" <<endl;
	cout << "+-Enter your name: ";
    cin.getline (msg,SIZE); cout << "|                                                |" << endl;
    cout << "+------------------------------------------------+" << endl;
    cout <<"|                                                |" <<endl;
	cout <<"+-So your name is "<< msg << "!" <<endl;
	cout <<"|                                                |" <<endl;
	cout << "+------------------------------------------------+" << endl;
	string msgstr(msg[SIZE],100);
    msgstr=name;
}
string charInfo::getName()
{
       return name;
}
void charInfo::levelUp() // levels the character subsequently adding 1 level and 5 hp
{
     int levinc = 1;
     int hpinc = 5;
     int mpinc = 13;
     privlevel = levinc + privlevel;
     privmana = mpinc + privmana;
     privhp= hpinc + privhp;     
}
void charInfo::setHp(int hitpoint) //sets the players hit points
{
     privhp=hitpoint;
}

int charInfo::getHp() // returns the players hit points
{
    return privhp;
}

void charInfo::setLevel(int level) // sets the players level
{
     privlevel=level;
}

int charInfo::getLevel() // returns the players level
{
    return privlevel;
}

int main()
{
    charInfo fire;
    cout << "+----------Welcome to my text based RPG----------+" << endl;
    cout << "|" << "                                                |"<< endl;                                       
    fire.setName();
    fire.setLevel(1);
    fire.setHp(10);
    cout << "+------------------------------------------------+" << endl;
    cout << endl;
    cout << "+-Character Name: " << fire.getName()<< endl;
    cout << "+-Level: " << fire.getLevel()<< endl;
    cout << "+-Life: " <<fire.getHp()<<endl;
    
    system("PAUSE");
    return 0;
    
}