-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacter.cpp
More file actions
55 lines (44 loc) · 1.31 KB
/
Character.cpp
File metadata and controls
55 lines (44 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/****************************************************************************************************
* * Program name: CS162 Project3
* * Author: Taekyoung Kim
* * Date: 02/05/2019
* * Description: This is Character.cpp file for CS162 Project3
* * This project demonstrates a fantasy combat game.
* * There are 5 characters that have different ability and power.
* * The real game is done with a dice.
******************************************************************************************************/
#include "Character.h"
#include <iostream>
#include <random>
Character::Character()=default;
Character::~Character()=default;
Character::Character(std::string n, int s, int a) {
this -> name = n;
this -> strength = s;
this -> armor = a;
}
std::string Character::getName() const {
return this -> name;
}
int Character::getStrength() const{
return this-> strength;
}
int Character::getArmor() const {
return this ->armor;
}
void Character::setStrength(int s){
strength = s;
}
int Character::Dice (int num, int side)const {
int output;
if(num <=0 ){
return 0;
}
else {
std::random_device ran;
std::mt19937 mt(ran());
std::uniform_int_distribution<int> dist(1, side);
output = dist(mt);
return(Dice(num-1, side) + output);
}
}