-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdice.cpp
More file actions
62 lines (51 loc) · 841 Bytes
/
dice.cpp
File metadata and controls
62 lines (51 loc) · 841 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
57
58
59
60
61
62
#include "dice.h"
#include <iostream>
using namespace std;
Dice::Dice()
{
using std::srand;
using std::time;
value = 0;
sides = 6;
clicked = false;
srand((unsigned int) time(0));
}
Dice::Dice(int dieSides)
{
using std::srand;
using std::time;
value = 0;
sides = dieSides;
clicked = false;
srand((unsigned int) time(0));
}
Dice::~Dice()
{}
int Dice::rollDie(int dieSides)
{
int returnValue;
int sides = dieSides;
returnValue = (rand() % sides) + 1;
if (clicked == false) {value = returnValue;}
return value;
}
void Dice::clickDie()
{
clicked = !clicked;
}
void Dice::setClicked()
{
clicked = false;
}
bool Dice::getClicked()
{
return clicked;
}
void Dice::setValue(int inputValue)
{
value = inputValue;
}
int Dice::getValue()
{
return value;
}