-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDice.cpp
More file actions
65 lines (58 loc) · 937 Bytes
/
Copy pathDice.cpp
File metadata and controls
65 lines (58 loc) · 937 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
63
64
/*
*
* Author: eric
*/
#include "Dice.hpp"
#include <cstdlib>
#include <ctime>
Dice::Dice() :
value( rand() % 6 + 1)
{
}
Dice::Dice( char aNumber) :
value( aNumber)
{
}
Dice::Dice( const Dice& aDice) :
value( aDice.value)
{
}
void Dice::setValue( char aNumber)
{
value = aNumber;
}
unsigned char Dice::getValue() const
{
return value;
}
std::string Dice::asString()
{
return ""+value;
}
bool Dice::operator==( const Dice& aDice) const
{
return aDice.value == value;
}
bool Dice::operator==( const char aNumber) const
{
return aNumber == value;
}
void Dice::operator=( const Dice& aDice)
{
value = aDice.value;
}
bool Dice::operator<( const Dice& aDice) const
{
return value < aDice.value;
}
bool Dice::operator<( const char aNumber) const
{
return value < aNumber;
}
Dice Dice::operator+(const Dice& aDice) const{
return Dice(value+aDice.value);
}
Dice::~Dice()
{
// TODO Auto-generated destructor stub
}