D&D Style Game

Pages: 12
Feb 14, 2016 at 12:41pm
Well, there's something wrong with your constructor that should be obvious when you look at it.

Also, you do know that you haven't followed the instructions for the signatures of the get*() methods, right?

I'd recommend defining constant symbols for those array indices for m_iCharTraits, rather than using magic numbers. It would make it easier to avoid mistakes.

Have you tested it? Are you happy that it's working as it's supposed to?
Feb 14, 2016 at 12:43pm
Hi,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
	Character(char name[], int cl, int al, int hp, int str, int dex, int con, int itl, int wis, int chr)
	{
		for(int i = 0; i < 64; i++)
		{
			m_sName[i] = name[i];
		}
		
		m_iClass = cl;
		m_iAlignment = al;
		m_iHitPoints = hp;
		m_iCharTraits[0] = str;
		m_iCharTraits[1] = dex;
		m_iCharTraits[0] = con;
		m_iCharTraits[0] = itl;
		m_iCharTraits[0] = wis;
		m_iCharTraits[0] = chr;
	}


You are overwriting iCharTraits[0] multiple times.

Missing the default constructor.

It didn't say you couldn't have a member initializer list, might pay to ask about that though.

I would also ask about the get functions should be marked const.

Maybe you guys haven't been taught about those last two things yet?

2.1.2.3.4 void getHitPoints(int& hp), void setHitPoints(int hp) - Get and set the player hit points. The get function shall be a reference function.


Your function doesn't have the reference parameter.

2.1.2.3.5 Six pairs of functions to get and set the various character traits stored in the m_iCharTraits array. All of the get functions shall be pointer functions. The functions are:
void getStrength(int *str), void setStrength(int str) - Get and set the player Strength score (m_iCharTraits[0]).
void getDexterity(int *dex), void setDexterity(int dex) - Get and set the player Dexterity score (m_iCharTraits[1]).
void getConstitution(int *cn), void setConstitution(int cn) - Get and set the player Constitution score (m_iCharTraits[2]).
void getIntelligence(int *itl), void setIntelligence(int itl) - Get and set the player Intelligence score (m_iCharTraits[3]).
void getWisdom(int *wis), void setWisdom(int wis) - Get and set the player Wisdom score (m_iCharTraits[4]).
void getCharisma(int *chr), void setCharisma(int chr) - Get and set the player Charisma score (m_iCharTraits[5]).


Your functions should be void not int, otherwise there is no point in sending a pointer.
Edit: so you need to dereference the pointer and set it's value.
Good Luck!!
Last edited on Feb 14, 2016 at 1:20pm
Feb 29, 2016 at 5:05pm
My apologies. I finished the assignment, but I do not want to post the finished product here. If you would like to see what I came up with, let me know and I'll send it in a message.
Topic archived. No new replies allowed.
Pages: 12