Last active
April 28, 2020 22:34
-
-
Save Kijimu7/12b540e91a50ea5b5fee289a50290c25 to your computer and use it in GitHub Desktop.
Error on line 91 to 99 E0289 no instance of constructor "Student::Student" matches the argument list argument types are: (std::string, std::string, std::string, std::string, int, int, DegreeProgram)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include<iostream> | |
#include<iomanip> | |
#include<string> | |
using std::string; | |
//enumurated data type data type values | |
enum DegreeProgram {SECURITY, NETWORK, SOFTWARE}; | |
static const std::string degreeProgramString[] = { "SECURITY", "NETWORK", "SOFTWARE" }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include "roster.h" | |
//#include <sstream> | |
using std::cout; | |
using std::endl; | |
using std::string; | |
using namespace std; | |
int main() | |
{ | |
cout << "SCRIPTING AND PROGRAMMING APPLICATION C867\n"; | |
cout << "C++ WGU ID MY name\n"; | |
const int numStudents = 5; | |
string studentData[numStudents] = | |
{ | |
"A1,John,Smith,John1989@gm ail.com,20,30,35,40,SECURITY", | |
"A2,Suzan,Erickson,Erickson_1990@gmailcom,19,50,30,40,NETWORK", | |
"A3,Jack,Napoli,The_lawyer99yahoo.com,19,20,40,33,SOFTWARE", | |
"A4,Erin,Black,[email protected],22,50,58,40,SECURITY", | |
"A5,Sssss,Hhhhh,[email protected],31,25,34,31,SOFTWARE" | |
}; | |
cout << "parse student data: \n"; | |
Roster classRoster; | |
cout << "Parsing data and adding students:\t"; | |
for (int i= 0; i < numStudents; i++) | |
{ | |
classRoster.parseAdd(studentData[i]); | |
} | |
cout << "DONE.\n"; | |
cout << "Displaying all students:\n"; | |
classRoster.print_All(); | |
cout << "\n"; | |
classRoster.printInvalidEmails(); | |
cout << "\n"; | |
//loop through classRosterArray and for each element: | |
//classRoster.printAverageDaysInCourse(/*current_object's student id*/); | |
for (int i = 0; i < 3; i++) { | |
classRoster.printAverageDaysInCourse(classRoster.classRosterArray[i].getID()); | |
} | |
cout << "\n\n"; | |
classRoster.printByDegreeProgram(SOFTWARE); | |
cout << "\n"; | |
cout << "Expected: Did not find student A3 to remove from roster. \n"; | |
classRoster.remove("A3"); | |
classRoster.print_All(); | |
classRoster.remove("A3"); | |
system("pause"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "roster.h" | |
#include<string> | |
using std::string; | |
Roster::Roster(){ | |
/*this->capacity = 0;*/ | |
//this->lastIndex = -1;//Empty | |
/*this->classRosterArray = nullptr;*/ | |
} | |
void Roster::parseAdd(string row) | |
{ | |
if (lastIndex < 5) { | |
lastIndex++; | |
DegreeProgram degree; | |
if (row.back() == 'Y')degree = SECURITY; | |
else if (row.back() == 'E')degree = SOFTWARE; | |
else if (row.back() == 'K') degree = NETWORK; | |
int rhs = row.find(","); | |
string studentID = row.substr(0, rhs); | |
int lhs = rhs + 1; | |
rhs = row.find(",", lhs); | |
string firstName = row.substr(lhs, rhs - lhs); | |
lhs = rhs + 1; | |
rhs = row.find(",", lhs); | |
string lastName = row.substr(lhs, rhs - lhs); | |
lhs = rhs + 1; | |
rhs = row.find(",", lhs); | |
string emailAddress= row.substr(lhs, rhs - lhs); | |
lhs = rhs + 1; | |
rhs = row.find(",", lhs); | |
int age = stoi(row.substr(lhs, rhs - lhs)); | |
lhs = rhs + 1; | |
rhs = row.find(",", lhs); | |
int daysInCourse1 = stoi(row.substr(lhs, rhs - lhs)); | |
lhs = rhs + 1; | |
rhs = row.find(",", lhs); | |
int daysInCourse2 = stoi(row.substr(lhs, rhs - lhs)); | |
lhs = rhs + 1; | |
rhs = row.find(",", lhs); | |
int daysInCourse3 = stoi(row.substr(lhs, rhs - lhs)); | |
//call add function | |
add(studentID, firstName, lastName, emailAddress, age, | |
daysInCourse1, daysInCourse2, daysInCourse3, degree); | |
} | |
} | |
void Roster::add(string studentID, string firstName, string lastName, string emailAddress, int age, | |
int daysInCourse1, int daysInCourse2, int daysInCourse3, DegreeProgram degreeprogram) | |
{ | |
int days[Student::daysArray]; | |
days[0] = daysInCourse1; | |
days[1] = daysInCourse2; | |
days[2] = daysInCourse3; | |
if (degreeprogram == SECURITY) { | |
classRosterArray[lastIndex] = new Student(studentID, firstName, lastName, emailAddress, age, days, degreeprogram); | |
} | |
else if (degreeprogram == NETWORK) { | |
classRosterArray[lastIndex] = new Student(studentID, firstName, lastName, emailAddress, age, days, degreeprogram); | |
} | |
else { | |
classRosterArray[lastIndex] = new Student(studentID, firstName, lastName, emailAddress, age, days, degreeprogram); | |
} | |
} | |
void Roster::print_All() | |
{ | |
for (int i = 0; i <= this->lastIndex; i++) { | |
(this->classRosterArray)[i]->print(); | |
} | |
} | |
bool Roster::remove(string studentID) | |
{ | |
bool found = false; | |
for (int i = 0; i <= lastIndex; i++) | |
{ | |
if (this->classRosterArray[i]->getID() == studentID) | |
{ | |
found = true; | |
delete this->classRosterArray[i]; | |
this->classRosterArray[i] = this->classRosterArray[lastIndex]; | |
lastIndex--; | |
} | |
} | |
return found; | |
} | |
void Roster::printAverageDaysInCourse(string studentID) | |
{ | |
//int i = 0; | |
//while (classRosterArray[i]->getID() != studentID && i < 5) { | |
// ++i; | |
//} | |
bool found = false; | |
for (int i = 0; i <= lastIndex; i++) | |
{ | |
if (this->classRosterArray[i]->getID() == studentID) | |
{ | |
found = true; | |
int* days = classRosterArray[i]->getDays(); | |
cout << "Average days in course " << classRosterArray << " is " << (days[0] + days[1] + days[2]) / 3; | |
} | |
if (!found)cout << "Did not find student!\n"; | |
} | |
} | |
//void Roster::printInvailidDaysEntries() | |
//{ | |
// cout << "Displaying invaild days entries:\n"; | |
// for (int i = 0; i <= lastIndex; i++) | |
// { | |
// cout << "Student ID: " << classRosterArray[i]->getID() << ":"; | |
// bool any = false; | |
// int* days = classRosterArray[i]->getDays(); | |
// for (int j = 0; j < Student::daysArray; j++) | |
// { | |
// if (days[j] < 0) | |
// { | |
// any = true; | |
// cout << days[j] << " "; | |
// } | |
// } | |
// if (!any) cout << "NONE"; | |
// cout << "\n"; | |
// } | |
//} | |
void Roster::printInvalidEmails() | |
{ | |
for (int i = 0; i <= lastIndex; i++) | |
{ | |
string emailAddress = classRosterArray[i]->getEmail(); | |
if ((emailAddress.find("@") == string::npos) || (emailAddress.find(".") == string::npos) || (emailAddress.find(" ") != string::npos)) | |
{cout << "Email Address for: " << classRosterArray[i]->getFirstname()<<" "<< | |
classRosterArray[i]->getLastname()<<"is not valid. " << emailAddress << '\n'; | |
} | |
} | |
} | |
void Roster::printByDegreeProgram( DegreeProgram d) | |
{ | |
cout << "Printing degree program \t" << degreeProgramString[d] << '\n'; | |
for (int i = 0; i <= lastIndex; i++) { | |
if (this->classRosterArray[i]->getDegreeProgram() == d) this->classRosterArray[i]->print(); | |
} | |
} | |
Roster::~Roster() { | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include<string> | |
#include<iostream> | |
#include "student.h" | |
using namespace std; | |
// creat student table | |
//E. Create a Roster class | |
class Roster { | |
private: | |
Student* classRosterArray[5]; | |
public: | |
Roster(); | |
//E.3 Add void add fucntion | |
void add(string studentID, string firstName, string lastName, string emailAddress, int age, | |
int daysInCourse1, int daysInCourse2, int daysInCourse3, DegreeProgram degreeprogram); | |
int lastIndex = -1; | |
void parseAdd(string row); | |
void print_All(); | |
bool remove(string studentID); | |
void printAverageDaysInCourse(string studentID); | |
void printByDegreeProgram(DegreeProgram d); | |
void printInvalidEmails(); | |
/*bool printInvailidDaysEntries()*/; | |
const int numStudents = 5; | |
~Roster(); | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include<iomanip> | |
#include"student.h" | |
using std::string; | |
using std::cout; | |
using std::cerr; | |
using namespace std; | |
Student::Student() //Empty constructor | |
{ | |
} | |
//full constructor | |
Student::Student(string ID, string firstName, string lastName, string email, int Age, int days[], DegreeProgram type) | |
{ | |
this->studentID = ID; | |
this->firstName = firstName; | |
this->lastName = lastName; | |
this->Email = email; | |
this->age = Age; | |
for (int i = 0; i < 3; i++) this->days[i] = days[i]; | |
this->dtype = type; | |
} | |
//getters | |
string Student::getID() | |
{ | |
return studentID; | |
} | |
string Student::getFirstname() | |
{ | |
return firstName; | |
} | |
string Student::getLastname() | |
{ | |
return lastName; | |
} | |
string Student::getEmail() | |
{ | |
return Email; | |
} | |
int Student::getAge() | |
{ | |
return age; | |
} | |
int* Student::getDays() | |
{ | |
return days; | |
} | |
DegreeProgram Student::getDegreeProgram() | |
{ | |
return dtype; | |
} | |
//Setters | |
void Student::setID(string ID) | |
{ | |
studentID = ID; | |
} | |
void Student::setFirstname(string firstname) | |
{ | |
this->firstName = firstName; | |
} | |
void Student::setLastname(string lastname) | |
{ | |
this->lastName = lastName; | |
} | |
void Student::setEmail(string email) | |
{ | |
this->Email = Email; | |
} | |
void Student::setAge(int age) | |
{ | |
this->age = age; | |
} | |
void Student::setDays(int days[]) | |
{ | |
for (int i = 0; i < 3; i++) this->days[i] = days[i]; | |
} | |
void Student::setDegreeProgram(DegreeProgram d) | |
{ | |
this->dtype = d; | |
} | |
void Student::print() | |
{ | |
//E3C | |
/*cout << "A1\t First Name : John\t Last Name : Smith\t Age : 20\tdaysInCourse : {35, 40, 55} Degree Program : Security.";*/ | |
cout << "ID " << getID() << "\t" | |
<< "First Name: " << getFirstname() << "\t" | |
<< "Last Name: " << getLastname() << "\t" | |
<< "Age: " << getAge() << "\t" | |
<< "daysInCourse: {" << days[0] << " " << days[1] << " " << days[2] << "}" <<"\t" | |
<< "DegreeProgram: " << degreeProgramString[getDegreeProgram()] << "\t" << "\n"; | |
} | |
Student::~Student() | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <string> | |
#include<iostream> | |
#include "degree.h" | |
using std::string; | |
class Student | |
{ | |
//D1. create variables | |
private: | |
string studentID; | |
string firstName; | |
string lastName; | |
string Email; | |
int age; | |
DegreeProgram dtype; | |
public: | |
const static int daysArray = 3; | |
int days[daysArray]; | |
Student(); // empty constructor | |
//constractor | |
Student(string ID, string firstName, string lastName, string email, int Age, int days[], DegreeProgram type); | |
//create function getter | |
string getID(); | |
string getFirstname(); | |
string getLastname(); | |
string getEmail(); | |
int getAge(); | |
int* getDays(); | |
DegreeProgram getDegreeProgram(); | |
//create setter | |
void setID(string studentID); | |
void setFirstname(string firstname); | |
void setLastname(string lastname); | |
void setEmail(string email); | |
void setAge(int age); | |
void setDays(int days[]); | |
void setDegreeProgram(DegreeProgram d); | |
void print(); | |
// destructor | |
~Student(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment