Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
gaming-project/sword class
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
62 lines (47 sloc)
985 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
using namespace std; | |
class Sword : public weapons | |
{ | |
private: | |
int sharpness, range; | |
public: | |
Sword(int _sharpness,int _range) : weapons(_damage , _durability, _name) | |
{ | |
sharpness = _sharpness; | |
range = _range; | |
} | |
void setSharpness(_sharpness) | |
{ | |
sharpness = _sharpness; | |
} | |
int getSharpness() | |
{ | |
return sharpness; | |
} | |
void setRange(_range) | |
{ | |
range = _range; | |
} | |
int getRange(_range) | |
{ | |
return range; | |
} | |
}; | |
#include "sword.h" | |
#include <string> | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
Sword Sword_sharpnessobj; | |
sword_sharpnessobj.setSharpness(100); | |
cout<< sword_sharpnessobj.getSharpness()<< endl; | |
Sword sword_rangeobj; | |
sword_rangeobj.setRange(5); | |
cout << sword_rangeobj.getRange()<<endl; | |
Sword swordObj(100, 50, "katana"); | |
cout << swordObj.getDamage() << endl; | |
cout << swordObj.getDurability()<<endl; | |
cout << swordObj.getName()<<endl; | |
}; |