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
e755f593
Commit
e755f593
authored
Mar 14, 2018
by
Andrew Binder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Error checking for userrnames
parent
899b96b2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
Teacher.cpp
Teacher.cpp
+20
-9
Teacher.h
Teacher.h
+3
-1
No files found.
Teacher.cpp
View file @
e755f593
...
@@ -15,7 +15,7 @@ ifstream fin;
...
@@ -15,7 +15,7 @@ ifstream fin;
// Input: none
// Input: none
// Output: object with teacher username of NULL
// Output: object with teacher username of NULL
Teacher
::
Teacher
()
{
Teacher
::
Teacher
()
{
userName
=
"
NULL
"
;
userName
=
"
teacher
"
;
}
}
// Default Constructor
// Default Constructor
...
@@ -69,7 +69,7 @@ void Teacher::displayMenu() {
...
@@ -69,7 +69,7 @@ void Teacher::displayMenu() {
cout
<<
"Your username is currently "
<<
userName
<<
"."
<<
endl
;
cout
<<
"Your username is currently "
<<
userName
<<
"."
<<
endl
;
cout
<<
"Please input a new username: "
;
cout
<<
"Please input a new username: "
;
cin
>>
stringIn
;
cin
>>
stringIn
;
setUserName
(
stringIn
);
setUserName
(
stringIn
);
// ******* Check for student username
break
;
break
;
case
6
:
// Change Exit Code
case
6
:
// Change Exit Code
cout
<<
"The exit code is currently "
<<
exitCode
<<
"."
<<
endl
;
cout
<<
"The exit code is currently "
<<
exitCode
<<
"."
<<
endl
;
...
@@ -177,6 +177,8 @@ void Teacher::importProgress() {
...
@@ -177,6 +177,8 @@ void Teacher::importProgress() {
void
Teacher
::
enrollStudent
(
string
studentIn
)
{
void
Teacher
::
enrollStudent
(
string
studentIn
)
{
int
validName
=
checkRoster
(
studentIn
);
// Check if username exists in roster
int
validName
=
checkRoster
(
studentIn
);
// Check if username exists in roster
// Check for teacher username ***********
// If the name is valid, enroll the student, otherwise output an error
// If the name is valid, enroll the student, otherwise output an error
if
(
validName
==
-
1
)
{
if
(
validName
==
-
1
)
{
roster
.
push_back
(
studentIn
);
roster
.
push_back
(
studentIn
);
...
@@ -192,6 +194,11 @@ void Teacher::enrollStudent(string studentIn) {
...
@@ -192,6 +194,11 @@ void Teacher::enrollStudent(string studentIn) {
void
Teacher
::
adjustProgress
(
string
studentUserNameIn
,
int
level
)
{
void
Teacher
::
adjustProgress
(
string
studentUserNameIn
,
int
level
)
{
int
studentNumber
=
checkRoster
(
studentUserNameIn
);
// Check if student exists/Get student position in vector
int
studentNumber
=
checkRoster
(
studentUserNameIn
);
// Check if student exists/Get student position in vector
Student
*
studentLevel
=
new
Student
;
if
(
level
>
studentLevel
.
getMaxLevel
())
{
cout
<<
"Error: Level too high!"
<<
endl
;
}
else
{
// If the username exists, change the level and output success to console
// If the username exists, change the level and output success to console
// Otherwise, output an error
// Otherwise, output an error
if
(
studentNumber
>=
0
)
{
if
(
studentNumber
>=
0
)
{
...
@@ -201,7 +208,9 @@ void Teacher::adjustProgress(string studentUserNameIn, int level) {
...
@@ -201,7 +208,9 @@ void Teacher::adjustProgress(string studentUserNameIn, int level) {
}
else
{
}
else
{
cout
<<
"Error: Student not found!"
<<
endl
;
cout
<<
"Error: Student not found!"
<<
endl
;
}
}
}
delete
studentLevel
;
}
}
// Saves and ends program safely and gracefully
// Saves and ends program safely and gracefully
...
@@ -244,6 +253,8 @@ void Teacher::setExitCode(string exitCodeIn) {
...
@@ -244,6 +253,8 @@ void Teacher::setExitCode(string exitCodeIn) {
void
Teacher
::
setUserName
(
string
userNameIn
)
{
void
Teacher
::
setUserName
(
string
userNameIn
)
{
userName
=
userNameIn
;
userName
=
userNameIn
;
// Check if username exists in student vector ********
}
}
void
Teacher
::
setStudent
(
Student
studentIn
)
{
void
Teacher
::
setStudent
(
Student
studentIn
)
{
...
...
Teacher.h
View file @
e755f593
...
@@ -56,3 +56,5 @@ class Teacher {
...
@@ -56,3 +56,5 @@ class Teacher {
};
};
#endif //TEACHER_H
#endif //TEACHER_H
//
\ No newline at end of file
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