Can anyone see the problem with my method ATTACK

#include "Monster.h"
#include "Player.h"
#include "Weapon.h"
#include <iostream>
using namespace std;


Monster::Monster(std::string Name, int health, int hitPoints,
		    int miss, int damage,const std::string& weaponName)

{
	Name = Name;
	hitPoints = hitPoints;
	Weapon weapon;
	miss = miss;
	damage = damage;
	weapon.Name = weaponName;



}

bool Monster::Death()
{
	return hitPoints <= 0;
}
std::string Monster::getName()
{
	return Name;
}


void Monster::attack(Player& player)
{
	cout << "A " << Name << " attacks you "
		<<"with a " << weapon.Name << endl;
		int damage = weapon.weaponHitPoints;
		int totalDamage = damage;
		if(totalDamage <= 0)
		{
			cout << "The monster's attack failed to "
				<< "penetrate your armour." << endl;
		}
		else
		{
			cout << "You are hit for " << totalDamage
				<< " damage!" << endl;
			player.takeDamage(totalDamage);
		}
	}
	else 
	{
		cout << "The " << Name << "missed!" << endl;
	}
	cout << endl;
}

Did you figure the problem out? I see it is marked as solved but you didn't edit your post or post your solution.

The problem I see is that you are missing an if() to go with your bottom else statement.

Did you figure the problem out? I see it is marked as solved but you didn't edit your post or post your solution.

The problem I see is that you are missing an if() to go with your bottom else statement.

Ye thanks i figured it out i just had a block on my brain lol. Thanks anyway.

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.