-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistgen.cpp
126 lines (107 loc) · 2.46 KB
/
listgen.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
This file is part of RMQG.
RMQG is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
RMQG is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with RMQG. If not, see <http://www.gnu.org/licenses/>.
*/
// Copyright (C) 2011 - 2022 Peter Wright
// Author: Peter Wright
// Random Maths Question Generator (RMQG)
#include "types.h"
#include "global.h"
void Listgen(string Opt1, string Opt2, string Opt3, string Opt4, string Opt5, string Filename)
{
if(Opt1 == "-b" || Opt1 == "1")
{
qtype1 = 1;
BRangeMin = stoi(Opt2);
BRangeMax = stoi(Opt3);
}
else if(Opt1 == "-d" || Opt1 == "2")
{
qtype1 = 2;
DRangeMin = stoi(Opt2);
DRangeMax = stoi(Opt3);
}
if(Opt4 == "-m" || Opt4 == "1")
{
qtype2 = 1;
qtypecl = "x";
}
else if(Opt4 == "-a" || Opt4 == "2")
{
qtype2 = 2;
qtypecl = "+";
}
else if(Opt4 == "-s" || Opt4 == "3")
{
qtype2 = 3;
qtypecl = "-";
}
else if(Opt4 == "-d" || Opt4 == "4")
{
qtype2 = 4;
qtypecl = "/";
}
else if (Opt4 == "-r" || Opt4 == "5")
{
qtype2 = 5;
}
ofstream Qlist_file(Filename, ios::out | ios::app);
if(Qlist_file.is_open())
{
int LineCount = stoi(Opt5);
Qlist_file << "Line count=" << LineCount << endl;
for(int i = 0; i <= LineCount; i++ )
{
if(qtype1 == 1)
{
GrandnumB();
}
else if(qtype1 == 2)
{
GrandnumD();
}
if (qtype2 == 5)
{
int RandOptCL = GrandOpt();
switch (RandOptCL)
{
case 0:
{
qtypecl = "x";
break;
}
case 1:
{
qtypecl = "+";
break;
}
case 2:
{
qtypecl = "-";
break;
}
case 3:
{
qtypecl = "/";
break;
}
}
}
Qlist_file << qnum1 << qtypecl << qnum2 << "=" << endl;
}
}
else
{
cout << "Unable to open file." << endl;
}
Qlist_file.close();
}