forked from CEN4020-Fall/assignment2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtank.cpp
More file actions
56 lines (49 loc) · 993 Bytes
/
tank.cpp
File metadata and controls
56 lines (49 loc) · 993 Bytes
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
//
//Kristen Davis
//
#include <cstdlib>
#include <ctime>
#include "Tank.h"
Tank::Tank() {
nickname="Company X"
setMisson("Training");
camoflauge="desert";
setnumberofGuns(2);
}
Tank::Tank(string camo, string n,string m, int num=2) {
camoflauge=camo;
setMisson(m);
nickname=n;
setNumberofGuns(num);
}
Tank::~Tank() = default;
void Tank::getnumberofGuns() {
return numberofGuns;
}
void Tank::setMisson(string m);
{
misson=m;
}
double Tank::mileageEstimate(double time) {
double mileage=0;
if(misson=="training")
{
mileage=(rand()%(25-10 +1)+10)*time;
}
else if(misson=="desert")
{
mileage=(rand()%(45-10 +1)+10)*time;
}
else
{
mileage=(rand()%(55-10 +1)+10)*time;
}
return mileage;
}
string Tank::toString() {
return "-> Tank\n" + PoweredVehicle::toString() + "\n Number of Guns: " +
to_string(numberofGuns);
void Tank::setNumberofGuns(int ne)
{
numberofGuns=ne;
}