-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_op.cpp
56 lines (46 loc) · 920 Bytes
/
random_op.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
#include "random_op.h"
#include <cstdlib>
// constructor
Random_operation::Random_operation( unsigned int seed, int range )
{
current_range = range;
srand( seed );
Randomize_next_op();
}
void Random_operation::Set_seed( unsigned int seed )
{
srand( seed );
Randomize_next_op();
}
void Random_operation::Randomize_next_op()
{
int random_number;
random_number = rand()%4;
switch( random_number )
{
case 0:
case 1:
current_operation = 'G';
break;
case 2:
current_operation = 'D';
break;
case 3:
current_operation = 'I';
}
random_number = rand()%current_range + 1;
current_key = random_number;
current_data = random_number;
}
char Random_operation::Get_op()
{
return current_operation;
}
int Random_operation::Get_key()
{
return current_key;
}
int* Random_operation::Get_data()
{
return ¤t_data;
}