-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlight_saber.cpp
54 lines (47 loc) · 1.25 KB
/
light_saber.cpp
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
#include "light_saber.h"
#include <stdexcept>
namespace da_game {
LightSaber::LightSaber(unsigned int attack, float ratio) : Weapon(attack, ratio) {
// this->strength = attack;
// if (ratio >= 0 && ratio <= 1) {
// this->ratio = ratio;
// }
// else {
// // Shouldnt happen
// this->ratio = 0;
// throw std::out_of_range("index out of range");
// }
}
int LightSaber::weight() const {
return 5;
}
int LightSaber::volume() const {
return 5;
}
int LightSaber::price() const {
return 1000;
}
std::string LightSaber::type() const {
return " light saber";
std::string return_value = "";
switch (id % 5) {
case 0:
return_value = "Red";
break;
case 1:
return_value = "Blue";
break;
case 2:
return_value = "Green";
break;
case 4:
return_value = "Purple";
break;
case 5:
return_value = "Black";
break;
}
return_value += " light saber";
return return_value;
}
}