You have been contracted by a small college named CSU that would like for you to implement a custom software system for managing students data. As a prototype you decided to show them a menu driven example. Your menu driven example has the following features:
A) Show/Edit student information
B) Add courses to student schedule
C) Remove courses from student schedule
D) Display the entire university (alphabetical by last name)
E) Search for student by first name or last name
F) Access to the database requires a user account and password authentication
* Who is the user? The user of your system is the registrar/administrators. It is NOT intended to be used by students to access their records. Therefore, you only need a few login ids such as registrar, deans, etc.
* Menus: It is your responsibility to develop your own menu structure. You must make sure that all features are available on the menu.
* Files: All student data must be stored in the file system. You may use any file organization. Files can only be read at the start of the program and before the program exits.
* Classes: Your software is designed using at least three classes: Student, Undergraduate (inherits from Student), and Graduate (inherits from Student).
You are encouraged to include other classes as you deem necessary to make exploit the most reasonable OO design.
* C++ Features: You should incorporate as much as is reasonable from the first half of the semester: classes, constructors, destructors, setters/getters, inheritance, polymorphism, operator overloading, exceptions, templates, etc. Of course any topics from C++ I may also be used.
The Student class provides the basic framework for creating subclasses. It will contain the following attributes:
? First and Last Name of the student
? Student ID (9 digits, starting with the number 900)
- Major
? Current class schedule
? Current enrolled course hours
The Undergraduate class has at least the following responsibilities:
? The student's classification: Freshman, Sophomore, Junior, Senior
The Graduate class has at least the following responsibilities:
? The Degree type: Specialist, Master, Doctorate
? Thesis Topic
Notice that the requirements are minimal requirements. This is because the students records management has some basic requirements. But as a software developer, you may see the need to add data and/or features.
10% Design Document
20% Style and comments
70% Usability, error checking, and performance of each menu function
i have this problem with this code for my vector i still have to add some functions to do the searches but i cant get my vector working firs.
This is the main class and the class with the problem in it. It on the last line.
// main cpp to test program
#include "password.h"
#include "fileVector.h"
#include <string>
#include <iostream>
#include <vector>
using namespace std;
int PrnMainMenu();
void getChoice();
void addEntry();
void addEntry(vector<fileVector> &StudentInfo, fstream& afile);
void enter();
int main()
{
vector<fileVector>StudentInfo ;
fstream fileData("StudentInfo.txt");
string password;
string userName;
cout<<"please enter name"<<endl;
cin>>userName;
cout<<"enter Password"<<endl;
cin>>password;
getcompareusernamePassword(userName, password);
getChoice();
system("pause");
}
void getChoice()
{
int choice = PrnMainMenu();
while (choice <=5)
{
switch (choice)
{
case 1:
enter();
break;
/*case 2:
SearchLastName();
break;
case 3:
DisplayAlphebetically();
break;
case 4:
editFiles();
break; */
default:
cout << "Please enter a valid number or enter 5 to exit." << endl;
break;
}
PrnMainMenu();
}
}
int PrnMainMenu()
{ int choice;
cout<<"\n\n\t MAIN MENU";
cout<<"\n\n\n\t Select one:";
cout<<"\n\n\t 1. Search students by First Name";
cout<<"\n\n\t 2. Search students by Last Name";
cout<<"\n\n\t 3. Display all Students Alphebetically";
cout<<"\n\n\t 4. Edit files";
cout<<"\n\n\t 5. Quit";
cout<<"\n\n\n\n\n\t Enter choice (1-6)===>";
cin>>choice;
while(choice<1 || choice>5)
{
cout<<"\nERROR...re-enter choice(1-5)===>";
cin>>choice;
}
return choice;
}
void enter()
{// Create a vector to hold studentinfo objects.
vector<fileVector>StudentInfo ;
fstream fileData("StudentInfo.txt");
// Get five entries from the user.
cout << "Creating entries in the student information...\n\n";
// for (int i = 0; i < 2; i++)
while (!fileData.eof())
{
addEntry(StudentInfo, fileData);
cout << "Entry added.\n";
cout << "------------------------\n";
}
StudentInfo.pop_back();
// Step through the vector, printing each
// object's data.
cout << "\nHere are the entries:\n";
cout << "-----------------------\n";
for (int i = 0; i <StudentInfo.size(); i++)
{
StudentInfo[i].print();
cout << "-----------------------\n";
}
// ... (populate the vector)
vector<fileVector>::iterator n;
cout<<"This the student iformation stored in vector \n"<<endl;
for (vector<fileVector>::iterator n =StudentInfo.begin();
n != StudentInfo.end();++n)
addEntry(StudentInfo, fileData);
fileData.close();
// return 0;
}
void addEntry(vector<fileVector> &StudentInfo, fstream& afile)
{
string firstname;
string lastname;
string idnumber;
string class1;
string class2;
string class3;
string hours;
string classification;
string degreetype;
string thesis;
// Get the person's first name.
cout << "Enter a person's first name: ";
getline(afile, firstname);
// Get the person's last name.
cout << "Enter the person's last name: ";
getline(afile, lastname);
// Get the person's id.
cout << "Enter the person's id number: ";
getline(afile, idnumber);
cout << "Enter the person's class1: ";
getline(afile, class1);
cout << "Enter the person's class2: ";
getline(afile, class2);
cout << "Enter the person's class3: ";
getline(afile, class3);
cout << "Enter the person's class hours: ";
getline(afile, hours);
cout << "Enter the person's classification ";
getline(afile, classification);
cout << "Enter the person's degree type: ";
getline(afile, degreetype);
cout << "Enter the person's thesis: ";
getline(afile, thesis);
// Create a studentvector object initialized with
// this data.
fileVector entry(string firstname,string lastname,string idnumber,string class1,
string class2,string class3,string hours,string classification,string degreetype, string thesis );
// Store the entry in the vector.
StudentInfo.push_back(entry); //!!!!This is Where the problem is!!!!
}
the following header file Student.h hold the information for each student
#ifndef STUDENT_H
#define STUDENT_H
#include <string>
#include <iostream>
using namespace std;
class Student
{
protected:
string FirstName;
string LastName;
string IDNumber;
string Major;
string ClassSchedule;
int EnrolledHours;
public:
//constructors
Student();
Student(string fname,string lname,string id,string schedule,int eh);
//mutators calls
void setFirstName(string fname);
void setLastName(string lname);
void setIDNumber(string id);
void setClassSchedule(string schedule);
void setEnrolledHours(int eh);
//accessors
string getFirstName();
string getLastName();
string getIDNumber();
string getClassSchedule();
int getEnrolledHours();
virtual void print();
};
#endif
this is student.cpp
#include "Student.h"
#include <string>
#include <iostream>
using namespace std;
Student::Student()
{
FirstName="";
LastName="";
IDNumber="";
ClassSchedule="";
EnrolledHours=0;
}
Student::Student(string fname,string lname,string id,string schedule,int eh)
{
FirstName=fname;
LastName=lname;
IDNumber=id;
ClassSchedule=schedule;
EnrolledHours=eh;
}
void Student::setFirstName(string fname)
{
FirstName=fname;
}
void Student::setLastName(string lname)
{
LastName=lname;
}
void Student::setIDNumber(string id)
{
IDNumber=id;
}
void Student::setClassSchedule(string schedule)
{
ClassSchedule=schedule;
}
void Student::setEnrolledHours(int eh)
{
EnrolledHours=eh;
}
string Student::getFirstName()
{
return FirstName;
}
string Student::getLastName()
{
return LastName;
}
string Student::getIDNumber()
{
return IDNumber;
}
string Student::getClassSchedule()
{
return ClassSchedule;
}
int Student::getEnrolledHours()
{
return EnrolledHours;
}
void Student::print()
{
cout<<FirstName<<LastName<< IDNumber<<Major <<ClassSchedule<< EnrolledHours<<endl;
}
the following class gets what degree they have and what their thesis topic was about
graduate.h
#ifndef GRADUATE_H
#define GRADUATE_H
#include <string>
#include <iostream>
#include "Student.h"
using namespace std;
class Graduate:public Student
{
protected:
string DegreeType;
string ThesisTopic;
public:
//constructor
Graduate();
//constructor overload
Graduate(string fname,string lname,string id,string schedule,int eh,string dt,string top);
//mutator functon calls
void setDegreeType(string dt);
void setThesisTopic(string top);
//accessor call
string getDegreeType();
string getThesisTopic();
virtual void print();
};
#endif
graduate.cpp
#include "Graduate.h"
#include "Student.h"
#include <string>
#include<iostream>
using namespace std;
Graduate::Graduate()
{
DegreeType="";
ThesisTopic="";
}
//constructor overload
Graduate::Graduate(string fname,string lname,string id,string schedule,int eh,string dt,string top):Student( fname, lname, id, schedule, eh)
{
setDegreeType(dt);
setThesisTopic(top);
}
void Graduate::setDegreeType(string dt)
{
DegreeType=dt;
}
void Graduate::setThesisTopic(string top)
{
ThesisTopic=top;
}
//accessor call
string Graduate::getDegreeType()
{
return DegreeType;
}
string Graduate::getThesisTopic()
{
return ThesisTopic;
}
void Graduate::print()
{
cout<<FirstName<<LastName<< IDNumber<<Major <<ClassSchedule<< EnrolledHours<<DegreeType<<ThesisTopic<<endl;
}
the following class determines if the undergraduate is junior, sophomore, etc.
undergraduate.h
#ifndef UNDERGRADUATE_H
#define UNDERGRADUATE_H
#include <string>
#include <iostream>
#include "Student.h"
using namespace std;
class Undergraduate:public Student
{
protected:
string Classification;
public:
//constructor
Undergraduate();
//constructor overload
Undergraduate(string fname,string lname,string id,string schedule,int eh,string cl);
//mutator functon calls
void setClassification(string cl);
//accessor call
string getClassification();
virtual void print();
};
#endif
undergraduate.cpp
#include "Undergraduate.h"
#include "Student.h"
#include <string>
#include<iostream>
using namespace std;
Undergraduate::Undergraduate()
{
Classification="";
}
//constructor overload
Undergraduate::Undergraduate(string fname,string lname,string id,string schedule,int eh,string cl):Student( fname, lname, id, schedule, eh)
{
setClassification(cl);
}
void Undergraduate::setClassification(string cl)
{
Classification=cl;
}
//accessor call
string Undergraduate::getClassification()
{
return Classification;
}
void Undergraduate::print()
{
cout<<FirstName<<LastName<< IDNumber<<Major <<ClassSchedule<< EnrolledHours<<Classification<<endl;
}
the followiing and last class will be used to hold the objects of student, undergraduate, and graduate.
filevector.h
#ifndef FILEVECTOR_H
#define FILEVECTOR_H
#include "Student.h"
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
//prototypes
// vector class
class fileVector :public Student
{
private:
string class1; //1st class
string class2; //second class
string class3; //third class
public:
// Constructor
fileVector();
fileVector(string fn, string ln,string num,string cl1,string sched,string cl2,string cl3,int h,string clf,string dt,string tt) ;
void setclass1(string cl1);
void setclass2(string cl2);
void setclass3(string cl3);
string getclass1();
string getclass2();
string getclass3();
vector<fileVector>StudentInfo ;
// print function
virtual void print();
void enter();
void addEntry(vector<fileVector> &StudentInfo, fstream& afile);
};
#endif
filevector.cpp
#include <iostream>
#include "fileVector.h"
#include <string>
#include <vector>
#include <fstream>
using namespace std;
fileVector::fileVector()
{
class1="";
class2="";
class3="";
}
fileVector::fileVector(string fn, string ln,string num,string sched,string cl1,string cl2,string cl3,int h,string clf,string dt,string tt) :Student( fn , ln , num, sched, h)
{
FirstName=fn;
LastName=ln;
IDNumber=num;
class1=cl1;
class2=cl2;
class3=cl3;
EnrolledHours=h;
// Classification=clf;
// degreetype=dt;
// thesis=tt;
}
void fileVector::setclass1(string cl1)
{
class1=cl1;
}
void fileVector:: setclass2(string cl2)
{
class2=cl2;
}
void fileVector::setclass3(string cl3)
{
class3=cl3;
}
string fileVector:: getclass1()
{
return class1;
}
string fileVector:: getclass2()
{
return class2;
}
string fileVector::getclass3()
{
return class3;
}
void fileVector::print()
{
cout<<FirstName<<LastName<< IDNumber<<Major <<ClassSchedule<< EnrolledHours<<class1<<class2<<class3<<endl;
}