I have to finish the code but I am having several errors with this and I can't figure it out can somebody give me some insight on what I can do to fix this and also explain what am I doing wrong.

Here are the errors I am getting
Error 1 error C2065: 'amno' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 22
Error 2 error C2065: 'safetyOn' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 25
Error 3 error C2065: 'maxAmmo' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 26
Error 4 error C2143: syntax error : missing ';' before '.' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 43
Error 5 error C2143: syntax error : missing ';' before '.' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 43
Error 6 error C2143: syntax error : missing ';' before '.' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 44
Error 7 error C2143: syntax error : missing ';' before '.' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 44
Error 8 error C2065: 'pP1' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 45
Error 9 error C2228: left of '.setRateOfFire' must have class/struct/union \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 45
Error 10 error C2228: left of '.maxAmmo' must have class/struct/union \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 46
Error 11 error C2228: left of '.setDestructivePower' must have class/struct/union \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 47
Error 12 error C2228: left of '.load' must have class/struct/union \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 48
Error 13 error C2228: left of '.showDestructivePower' must have class/struct/union \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 49
Error 14 error C2228: left of '.ammoRemaining' must have class/struct/union \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 50
Error 15 error C2228: left of '.showRateOfFire' must have class/struct/union \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 51
Error 16 error C2228: left of '.ammoRemaining' must have class/struct/union \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 54
Error 17 error C2228: left of '.load' must have class/struct/union \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab5Ex1\Lab5Ex1\Lab5Ex1.cpp 55

#include <string>
#include <iostream>
#include <iomanip>
using namespace std;

class plasmaPistol
{
private:
	int ammo;
	int rateOfFire;
	int destructivePower;
public:
	void pressTrigger(void);
	void load(int nmbrOfBolts);
	void setDestructivePower(int powerSetting);
	int showDestructivePower(void);
	void setRateOfFire(int boltsPerTriggerPress);
	int showRateOfFire(void);
	int ammoRemaining(void);
	plasmaPistol()
	{
		amno = 30;
		rateOfFire = 5;
		destructivePower = 5;
		safetyOn = false;
		maxAmmo =30;
	}
	
	plasmaPistol(int dp, int ma)
	{
		rateOfFire = 5;
		destructivePower = dp;
		safetyOn = false;
		maxAmmo = ma;
	}
};

int main()
{
	char answer = ' ';
	do
	{
		plasmaPistol.pP1();
		plasmaPistol.pP2(5, 30);
		pP1.setRateOfFire(5);
		pP1.maxAmmo = 100;
		pP1.setDestructivePower(5);
		pP1.load(30);
		cout << "Destructive Power: " << pP1.showDestructivePower() << endl;
		cout << "Number of bolts left: " << pP1.ammoRemaining << endl;
		cout << "Rate of fire: " << pP1.showRateOfFire << endl;
		cout << endl;
		cout << endl;
		cout << "Number of bolts left: " << pP1.ammoRemaining << endl << endl;
		pP1.load(30);
		cout << "Would You Like to Shoot Again?? (y/n)\n";
		 cin >> answer;
	}
	while (answer != 'n' || answer != 'N');
	return 0;
}

void plasmaPistol::pressTrigger(void) 
	//fires the plasma pistol and decreases the ammo count 
	//based on the rateOfFire property. The pistol should 
	//not fire if the safetyOn property is true.
{
	if(!safetyOn && ammo >= rateOfFire)
	{
		ammo -= rateOfFire;
	}
}

void plasmaPistol::load(int nmbrOfBolts) 
	//adds ammo bolts to the plasma pistol. The amount of 
	//ammo bolts in the plasma pistol can not exceed the maxAmmo property
{
	if(ammo+nmbrOfBolts > maxAmmo)
	{
		ammo += nmbrOfBolts;
	}
}

void plasmaPistol::setDestructivePower(int powerSetting) 
	//changes the destructive power of the plasma pistol
{
	int destructivePower = powerSetting;
	if(powerSetting > 10) 
	{
		destructivePower = 10;
	}
	else
	{
		if(powerSetting < 1)
		{
			destructivePower = 1;
		}
	}
}


int plasmaPistol::showDestructivePower(void) 
	//returns the value of the destructivePower property.
{
	return destructivePower;
}

void plasmaPistol::setRateOfFire(int boltsPerTriggerPress)
	//changes the number of plasma bolts fired by the plasma 
	//pistol. Ensures that the max and minimum values are not exceeded.
{
	rateOfFire = boltsPerTriggerPress;
	if(boltsPerTriggerPress > 10)
	{
		boltsPerTriggerPress = 10;
	}
	else
	{
		if(boltsPerTriggerPress < 1)
		{
			boltsPerTriggerPress = 1;
		}
	}
}

int plasmaPistol::showRateOfFire(void) 
	//returns the value of the rateOfFire property
{
	return rateOfFire;
}

int plasmaPistol::ammoRemaining(void) 
	//returns the amount of ammo remaining in the pistol
{
	return ammo;
}

The first error is simply a spelling error.

The next 2 errors are saying that your class is missing declarations for those variables.

Look at lines 43 and 44 based on other programs you've seen. How do they declare objects of a class?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.