为什么#include "container.h"报错说打不开source file啊,我完全不知道怎么回事,啊啊啊啊啊,求帮助
#ifndef _CONTAINER
#define _CONTAINER
#include
using namespace std;
class container
{
protected:
int numOfHeal;
int numOfMW;
public:
container();
void set(int heal_n, int mw_n);
int nOfHeal();
int nOfMW();
void display();
bool useHeal();
bool useMW();
};
container::container()
{
set(0, 0);
};
void container::set(int heal_n, int mw_n)
{
numOfHeal = heal_n;
numOfMW = mw_n;
};
int container::nOfHeal()
{
return numOfHeal;
};
int container::nOfMW()
{
return numOfMW;
};
void container::display()
{
cout << "Your bag contains: " << endl;
cout << "Heal(HP+100): " << numOfHeal << endl;
cout << "Magic Water (MP+80): " << numOfMW << endl;
};
bool container::useHeal()
{
numOfHeal--;
return 1;
};
//use magic water
bool container::useMW()
{
numOfMW--;
return 1;
};
#endif
#ifndef _PLAYER
#define _PLAYER
#include
#include
#include "container.h"
#include
using namespace std;
enum job { sw, ar, mg };
class player
{
friend void showinfo(player &p1, player &p2);
friend class swordsman;
protected:
int HP, HPmax, MP, MPmax, AP, DP, speed, EXP, LV;
string name;
job role;
container bag;
public:
virtual bool attack(player &p) = 0;
virtual bool specialatt(player &p) = 0;
virtual void isLevelUp() = 0;
void reFill();
bool death();
void isDead();
bool useHeal();
bool useMW();
void transfer(player &p);
void showRole();
private:
bool playerdeath;
};
void player::reFill()
{
HP = HPmax;
MP = MPmax;
}
bool player::death()
{
return playerdeath;
};
void player::isDead()
{
if (HP <= 0)
cout << name << " is Dead." << endl;
system("pause");
playerdeath = 1;
}
};
bool player::useHeal()
{
if (bag.nOfHeal()>0)
{
HP = HP + 100;
if (HP>HPmax)
HP = HPmax;
cout << name << " used Heal, HP increased by 100." << endl;
bag.useHeal();
system("pause");
return 1;
}
else
{
cout << "Sorry, you don't have heal to use." << endl;
system("pause");
return 0;
}
};
bool player::useMW()
{
if (bag.nOfMW()>0)
{
MP = MP + 100;
if (MP>MPmax)
MP = MPmax;
cout << name << " used Magic Water, MP increased by 100." << endl;
bag.useMW();
system("pause");
return 1;
}
else
{
cout << "Sorry, you don't have magic water to use." << endl;
system("pause");
return 0;
}
}
// possess opponent's items after victory
void player::transfer(player &p)
{
cout << name << " got" << p.bag.nOfHeal() << " Heal, and " << p.bag.nOfMW() << " Magic Water." << endl;
system("pause");
p.bag.set(p.bag.nOfHeal(), p.bag.nOfMW());
};
void player::showRole()
{
switch (role)
{
case sw:
cout << "Swordsman";
break;
case ar:
cout << "Archer";
break;
case mg:
cout << "Mage";
break;
default:
break;
}
};
// display character's job
void showRole()
{
system("cls");
cout << "##############################################################" << endl;
cout << "# Player" << setw(10) << p1.name << " LV. " << setw(3) << p1.LV
<< " # Opponent" << setw(10) << p2.name << " LV. " << setw(3) << p2.LV << " #" << endl;
cout << "# HP " << setw(3) << (p1.HP <= 999 ? p1.HP : 999) << '/' << setw(3) << (p1.HPmax <= 999 ? p1.HPmax : 999)
<< " | MP " << setw(3) << (p1.MP <= 999 ? p1.MP : 999) << '/' << setw(3) << (p1.MPmax <= 999 ? p1.MPmax : 999)
<< " # HP " << setw(3) << (p2.HP <= 999 ? p2.HP : 999) << '/' << setw(3) << (p2.HPmax <= 999 ? p2.HPmax : 999)
<< " | MP " << setw(3) << (p2.MP <= 999 ? p2.MP : 999) << '/' << setw(3) << (p2.MPmax <= 999 ? p2.MPmax : 999) << " #" << endl;
cout << "# AP " << setw(3) << (p1.AP <= 999 ? p1.AP : 999)
<< " | DP " << setw(3) << (p1.DP <= 999 ? p1.DP : 999)
<< " | speed " << setw(3) << (p1.speed <= 999 ? p1.speed : 999)
<< " # AP " << setw(3) << (p2.AP <= 999 ? p2.AP : 999)
<< " | DP " << setw(3) << (p2.DP <= 999 ? p2.DP : 999)
<< " | speed " << setw(3) << (p2.speed <= 999 ? p2.speed : 999) << " #" << endl;
cout << "# EXP" << setw(7) << p1.EXP << " Job: " << setw(7);
p1.showRole();
cout << " # EXP" << setw(7) << p2.EXP << " Job: " << setw(7);
p2.showRole();
cout << " #" << endl;
cout << "--------------------------------------------------------------" << endl;
p1.bag.display();
cout << "##############################################################" << endl;
};
#endif