Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
cptr142_group_project
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jared Sexton
cptr142_group_project
Commits
ead5cb67
Commit
ead5cb67
authored
Mar 02, 2018
by
Jared Sexton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Questions
parent
6fefa4b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
30 deletions
+46
-30
Question_driver.cpp
Question_driver.cpp
+4
-4
Questions.cpp
Questions.cpp
+42
-26
No files found.
Question_driver.cpp
View file @
ead5cb67
...
...
@@ -11,10 +11,10 @@ using namespace std;
int
main
()
{
Questions
questionList
;
questionList
.
addSubQuestion
(
4
);
questionList
.
addSubQuestion
(
4
);
questionList
.
addSubQuestion
(
4
);
questionList
.
addSubQuestion
(
4
);
questionList
.
addSubQuestion
(
7
);
questionList
.
addSubQuestion
(
7
);
questionList
.
addSubQuestion
(
7
);
questionList
.
addSubQuestion
(
7
);
return
0
;
}
\ No newline at end of file
Questions.cpp
View file @
ead5cb67
...
...
@@ -5,8 +5,9 @@
*/
#include "Questions.h"
#include <iostream>
#include <cstdlib>
#include <iostream> // For cout and cin
#include <cstdlib> // For srand and rand
#include <ctime> // For time(0)
using
namespace
std
;
void
Questions
::
mainQuestionAsk
(
int
level
)
{
...
...
@@ -41,7 +42,11 @@ bool Questions::countingQuestion(int level) {
cout
<<
"# "
;
}
cout
<<
"
\n
How many symbols are there? "
;
cin
>>
answer
;
if
(
!
(
cin
>>
answer
))
{
cin
.
clear
();
cin
.
ignore
(
256
,
'\n'
);
answer
=
-
1
;
}
if
(
countTo
==
answer
)
{
cout
<<
"Good job!
\n
"
;
return
true
;
...
...
@@ -52,56 +57,63 @@ bool Questions::countingQuestion(int level) {
}
bool
Questions
::
addSubQuestion
(
int
level
)
{
srand
(
time
(
0
));
int
maxNumber
;
switch
(
level
)
{
case
4
:
//
5
's
maxNumber
=
rand
()
%
4
;
case
4
:
//
4
's
maxNumber
=
4
;
break
;
case
5
:
maxNumber
=
rand
()
%
5
;
case
5
:
// 5's
maxNumber
=
5
;
break
;
case
6
:
maxNumber
=
rand
()
%
6
;
case
6
:
// 6's
maxNumber
=
6
;
break
;
case
7
:
maxNumber
=
rand
()
%
7
;
case
7
:
// 7's
maxNumber
=
7
;
break
;
case
8
:
maxNumber
=
rand
()
%
8
;
case
8
:
// 8's
maxNumber
=
8
;
break
;
case
9
:
maxNumber
=
rand
()
%
9
;
case
9
:
// 9's'
maxNumber
=
9
;
break
;
case
10
:
maxNumber
=
rand
()
%
10
;
case
10
:
// 10's
maxNumber
=
10
;
break
;
default:
cerr
<<
"Please see your teacher about your current level.
\n
"
;
break
;
}
// Initialize variables
int
userAnswer
,
correctAnswer
;
int
term1
,
term2
;
bool
add
=
true
;
// Determine if addition or subtraction
if
((
rand
()
%
2
)
==
0
)
{
add
=
false
;
}
// Make sure term1 is greater than term2 within the desired range.
do
{
term1
=
(
rand
()
%
maxNumber
)
+
1
;
term2
=
(
rand
()
%
maxNumber
)
+
1
;
}
while
(
term1
<
term2
);
// Determine if addition or subtraction
// if((term1 + term2) < (maxNumber / 2)) {
// add = false;
// }
// NOT WORKING
}
while
((
term1
<
term2
)
||
((
term1
+
term2
)
>
maxNumber
));
// Ask the Question
if
(
add
)
{
correctAnswer
=
term1
+
term2
;
cout
<<
"
\t
"
<<
term1
<<
endl
;
cout
<<
"+
\t
"
<<
term2
<<
endl
;
cout
<<
"-----------"
<<
endl
;
cout
<<
"
\t
"
;
cin
>>
userAnswer
;
if
(
!
(
cin
>>
userAnswer
))
{
cin
.
clear
();
cin
.
ignore
(
256
,
'\n'
);
userAnswer
=
-
1
;
}
}
else
{
correctAnswer
=
term1
-
term2
;
...
...
@@ -109,7 +121,11 @@ bool Questions::addSubQuestion(int level) {
cout
<<
"-
\t
"
<<
term2
<<
endl
;
cout
<<
"-----------"
<<
endl
;
cout
<<
"
\t
"
;
cin
>>
userAnswer
;
if
(
!
(
cin
>>
userAnswer
))
{
cin
.
clear
();
cin
.
ignore
(
256
,
'\n'
);
userAnswer
=
-
1
;
}
}
if
(
userAnswer
==
correctAnswer
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment