assignment help please!! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

assignment help please!!

I'm doing a part to a project where I'm making a weapon class and a test program. The weapon class has to have three private data members: two integers (hit_chance and stamina_required) and a string for the weapon type. There is suppossed to be two public member functions: a display function which prints out the private data members and a constructor (which takes 3 arguments to initialize the private data). My teacher wants us to split the Weapon class into Weapon.h and Weapon.cpp and to put the main() function in another file named assignment10.cpp
Then I'm writing a makefile to build the program.
Heres what I have for the Weapon.h:
[code] #include
2 using namespace std;
5 class Weapon {
6 private:
7 int hit_chance;
8 int stamina_required;
9 string weapon;
12 public:
13 void display(void);
14 Weapon(string weapon, int hit, int stamina);
16 };

[code] 1 #include "Weapon.h"
2 #include
3 #include
4 using namespace std;
6 Weapon:: Weapon(string weapon, int stamina, int hit)
7 {
8 stamina_required=stamina;
9 hit_chance=hit;
10 }
11 void Weapon::display(void)
12 {
13 cout << "hit chance=" << hit << endl;
14 cout << "stamina required=" << stamina << endl;
15 cout << "weapon type is" << weapon << endl;
16 }
17 [/code]

and assignment10.cpp:
[code] 1 using namespace std;
2 #include"Weapon.h"
4 int main()
6 {
7 Weapon w1 ("Lance", 13, 5);
8 w1.display();
9 return 0;
10 }[/code]

I can't get this code to compile, and I'm wondering if anyone can spot any errors in my code? I've been working on it forever and am really stuck! Anything would help! Thanks!


Sign In or Register to comment.