-
Notifications
You must be signed in to change notification settings - Fork 0
/
dice.cpp
56 lines (45 loc) · 2.11 KB
/
dice.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
55
56
/***************************************************************************************************
** Author: Michael Johnson
** Date: 7/16/2017
** Description: Definitions of Dice class functions
***************************************************************************************************/
#include "Dice.h"
/*******************************************************************************************************
** Default Dice Constructor
** Default constructor for Dice object setting object to 0 sides and regular dice
*******************************************************************************************************/
Dice::Dice()
{
this->sides = 0;
}
/*******************************************************************************************************
** Dice Constructor
** Constructor for Dice object setting sides and type to parameters passed
*******************************************************************************************************/
Dice::Dice(int n)
{
this->sides = n;
}
/*******************************************************************************************************
** Dice destructor
** Destructs object. This is a virtual destructor as called in header file
*******************************************************************************************************/
Dice::~Dice()
{
}
/*******************************************************************************************************
** roll function
** Rolls a random number for a Dice object between 1 and the number of sides
*******************************************************************************************************/
int Dice::roll()
{
return this->rollNum = rand() % sides + 1;
}
/*******************************************************************************************************
** getSides function
** Returns the number of sides of a Dice object
*******************************************************************************************************/
int Dice::getSides()
{
return this->sides;
}