Quantcast
Viewing all articles
Browse latest Browse all 2703

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:
 #include<string>
  2 using namespace std;
  3 
  4 
  5 class Weapon {
  6     private:
  7              int hit_chance;
  8              int stamina_required;
  9              string weapon;
 10 
 11 
 12     public:
 13           void display(void);
 14           Weapon(string weapon, int hit, int stamina);
 15 
 16 };
 17 


Weapon.cpp:
 1 #include "Weapon.h"
  2 #include<iostream>
  3 #include<string>
  4 using namespace std;
  5 
  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 


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


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!

Viewing all articles
Browse latest Browse all 2703

Trending Articles