By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,663 Members | 762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,663 IT Pros & Developers. It's quick & easy.

Please review to see if I am doing correctly

P: 1
Can anyone review my code and see if I am setting the private variables correctly in the following? I have a Shop class that has a function that calls for infomation to be read from an external file. The information is then read into an array of structs. The struct contains an instance of another class (Weapon) and an integer.

Below are the two classes:

class Weapon
int GetMinDamage();
void SetMinDamage(int minDmg);
int GetMaxDamage();
void SetMaxDamage(int maxDmg);
int GetCriticalMin();
void SetCriticalMin(int cMin);
int GetCriticalMult();
void SetCriticalMult(int cMult);
string GetName();
void SetName(string nam);
int minDamage;
int maxDamage;
int criticalMin;
int criticalMul;
string name;

class Shop
struct WeaponProduct
{ Weapon weapon;
int price;
Shop(string wFile, string aFile);
void Enter(Character& character);
WeaponProduct* wInventory;
int numWeapons;

The specification file for Shop is below....can anyone tell me if I am getting and then inserting the information correctly? If not, give me some direction?

The italicized & bolded section is my main concern

Shop::Shop(string wFile);
{ ifstream inFile;;
inFile >> numWeapons;
wInventory = new WeaponProduct[numWeapons];
for(int i = 0; i < numWeapons; i++)
string name;
int minD, maxD, cMin, cMulti;
getline(wFile, name);
inFile >> minD >> maxD >> cMin >> cMulti >> price;


Sep 23 '06 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,916
Looks about right apart from you haven't declared and you don't use price
Sep 23 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.