<code> knight k1;
87 cout << "What is the first knights name?" << endl;
88 cin >> nm;
89 cout << "What is knights stamina?" << endl;
90 cin >> stam;
91 cout << "What is knights weapon?" << endl;
92 cin >> type;
93 cout << "What is the weapon's hit chance?" << endl;
94 cin>> hc;
95 cout << "What is the weapon's stamina required to use?" << endl;
96 cin >> sr;
97
98 knight k1(nm,stam,type,hc,sr);
99 k1.display(void);
100
101 knight k2;
102 cout << "What is the second knights name?" << endl;
103 cin >> nm;
104 cout>> "What is" << name << "stamina?" << endl;
105 cin >> stam;
106 cout >> "What is knights weapon?" << endl;
107 cin>> type;
108 cout << "What is weapon's hit chance?" << endl;
109 cin >> hc;
110 cout << "What is weapon's stamina required?" << endl;
111 cin >> sr;
</code>
I fixed that part, but basically I am trying to figure out how to ask these questions and make them part of my code... here is what I have:
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
1 #include<iostream>
2 #include<string>
3 #include"Random.h"
4 using namespace std;
5
6 class Weapon{
7 public:
8 int hit_chance;
9 int stamina_required;
10 string weapon_type;
11 void display (void);
12 Weapon(string type, int sr, int hc);
13 int get_stamina_required(void);
14 bool did_you_hit(void);
15 };
16
17 void Weapon::display(void)
18 {
19 cout<< "hit chance is" << hit_chance << endl;
20 cout<< "stamina required is" << stamina_required << endl;
21 cout<< "weapon type is" << weapon_type<< endl;
22
23 }
24
25 int Weapon::get_stamina_required(void)
26 {
27 return stamina_required;
28 }
29
30 bool did_you_hit(void)
31 {
32 Random r(1,100);
33 bool hit=r.get();
34 if (hit_chance<=hit)
35 {
36 did_you_hit==false;
37
38 }
39 else
40 did_you_hit==true;
41 }
42
43 class Knight{
44 public:
45 int stamina;
46
47 bool attack();
48 knight(string n, int stam);
49 Weapon weapon_in_hand;
50 bool on_horse;
51 string name;
52 };
53
54 Knight:: knight(string n, int stam, &const Weapon)
55 {
56 }
57
58 bool Knight::on_horse
59 {
60 if (stam<=0)
61 {
62 return false;
63 }
64 cout << n << "is exhausted" << endl;
65 }
66
67 else
68 return true;
69 }
70
71 bool Knight::attack(const Weapon)
72 {
73
74 if ( on_horse==true)
75 { get_stamina_required;
76 stamina-=sr;
77 did_you_hit;
78
79 }
80
81 }
|