I have a small bug, every time I start this program it runs, but it ignores the condition and every number I type in it runs the Kill() function. I need it to run the Kill() function only if 1 is pressed, and the Die() function if 2 is pressed. Here is the code for the Header and the Main.cpp.
Code:
//main.cpp
#include <iostream>
//include Killclass.h
#include "Killclass.h"
//initialize the main function
int main()
{ //declare and initialize integers kill and die
int kill, die;
kill = 1;
die = 2;
//declares Player1 an object
Player Player1;
//declares an NPC EvilTaco, an object
Player EvilTaco;
//displayes text in red
std::cout << "Enter 1 to kill the taco, enter 2 to die from the taco: " << std::endl;
//if statements for dying and killing also, telling to enter a number
std::cin.ignore();
if(kill == 1)
{
EvilTaco.Kill();
}
else
{
Player1.Die();
}
system( "PAUSE" );
}
//Killclass.h
#include <iostream>
class Player
{
public:
void Kill() { std::cout << "You have killed the Evil Taco!" << std::endl; }
void Die() { std::cout << "You have been killed by the Evil Taco!" << std::endl; }
};
If someone can help that would be appreciated,
Thanks.
PS, I'm pretty sure it's the IF Command doing this, I don't think I have the values right.