Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#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; | ||
|
||
|
||
|
||
}; |