-
Notifications
You must be signed in to change notification settings - Fork 0
/
die.h
58 lines (50 loc) · 1.28 KB
/
die.h
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
#ifndef DIE_H
#define DIE_H
#include <iostream>
#include <fstream>
using namespace std;
class Die {
public:
/**
* Die constructor:
* Seed the random number generator, set the number of sides
* to 6, and assign a random value (1-numSides) to faceValue
*/
Die();
/**
* Die constructor:
* Seed the random number generator, set the number of sides
* to newNumSides, and assign a random value (1-numSides) to faceValue
*/
Die(int newNumSides);
/**
* getFaceValue
* @return the face value of the die
*/
int getFaceValue();
/**
* getNumSides
* @return the number of sides of the die
*/
int getNumSides();
/**
* setNumSides: change the number of the die sides and ignore it if invalid
* @param newNumSides
*/
void setNumSides(int newNumSides);
/**
* roll: assign a new random value to the die face
* @return the face value assigned
*/
int roll();
/**
* operator <<, overloads the insertion operator to print
* the face value of the die.
* @return the stream used
*/
friend ostream& operator <<(ostream &out, const Die &d);
private:
int faceValue; ///the face value of the die
int numSides; ///number of faces of the die
};
#endif