int main(){ Group g; g.add(Student("aaa","aaa")); g.add(Student("bbb","bbb")); g.add(Student("ccc","ccc")); g.showAll(); return 0; }
/******************************************************************************************************************************************************* Function Name: EditStudent() Purpose: take firstname and lastname of the student from the user to edit if the student is found edit the student else give a message student not found In Parameters: None out parameters: NONE Version: 4 Author: Lovejot Singh ********************************************************************************************************************************************************/ bool DBManager::EditStudent(){ char fName[25]; char lName[20]; cout<<"Edit Student"<<endl; cout<<"Please enter the first name of the student to edit (e.g. Barack)"; cin>>fName; cout<<"Please enter the last name of the student to edit (e.g. Barack)"; cin>>lName; Student stud= Student(fName,lName,"",-1); //creating a temp object of Student class to use == operator bool found=false; // found bool to check if the student was found for(int loop=0;loop<max;loop++){ // for loop to check if the name given by the user was found in the database if(Students[loop].GetID() != -1) if((stud == Students[loop])){ //using overlaoded eqaulsto operator found= true; cout<<"Student Found with name "; cout<<fName <<" "<< lName << endl; cout<<"Editing Name: "; cout << fName<<" "<<lName<<endl; Students[loop].EditStudent(); //calling edit function related to the student object break; } } if(!found){ //if the name was not found in the database let the user know cout<<"Student not Found !\n"; return true; } return true; }
void main() { Student CR7("CR7"); cout<<Student::nums()<<endl; Student s1; Student s2=Student("messi"); }
void test1(){ Professor(); int i; for(i=0;i<1;i++) { Student(i, 3); } while (1); }
void test3(){ Professor(); int i; for(i=0;i<10;i++) { Student(i, 25); } while (1); }
int main() { set<int, greater<int>> setA;//默认是set<T,less<T>>升序 setA.insert(11); setA.insert(22); setA.insert(33); setA.insert(22); setA.insert(44); setA.insert(55); setA.insert(22); setA.insert(3); for (set<int,greater<int>>::iterator it = setA.begin(); it != setA.end(); ++it) cout << *it << " "; cout << endl << "*******************" << endl; setA.erase(22); for (set<int, greater<int>>::iterator it = setA.begin(); it != setA.end(); ++it) cout << *it << " "; set<int>::iterator itF = setA.find(11);//find() int nFind = *itF; int iCount = setA.count(3);//count() //lower_bound(),upper_bound() set<int>::iterator itLower = setA.lower_bound(3); set<int>::iterator itUpper = setA.upper_bound(11); //pair pair<set<int>::iterator, set<int>::iterator> itPair = setA.equal_range(33); set<int>::iterator itFirst = itPair.first; set<int>::iterator itSecond = itPair.second; cout << endl << "*******************" << endl; set<Student, stuFunctor> stuA; stuA.insert(Student(3, "小明")); stuA.insert(Student(5, "小刚")); stuA.insert(Student(4, "小草")); stuA.insert(Student(1, "小花")); stuA.insert(Student(2, "小晶")); for (set<Student, stuFunctor>::iterator it = stuA.begin(); it != stuA.end(); ++it) cout << "ID: " <<it->ID<<"\t姓名: "<<it->Name<< endl; return 0; }
void Classroom::Clear() { for (IndexType col = 1; col < col_ - 1; col++) for (IndexType row = 1; row < row_ - 1; row++) { students_[row][col] = Student(); } ModifySide(); is_clean_ = true; }
Student StudentLinkedList::Retrieve(const Student &key) { Node *curr = mHead; while (curr) { if (curr->mData == key) { return curr->mData; } else { curr = curr->mNext; } } return Student(); }
void test5(){ Professor(); int i; for(i=0;i<100;i++) { int bloop = random()%5+2; Student(i, bloop); //printf("The number of questions for student %d is %d\n", i, bloop); usleep(random()%1000); } while (1); }
void test4(){ Professor(); int i,j; for(j=0;j<5;j++) { for(i=0;i<2;i++) { Student(i+j*2, random()%10+1); } sleep(50); } while (1); }
QList<Student> LoginManager::SearchStudents(QString keyword) { if(db.open()) { QList<Student> list; QString queryString = QString("SELECT * FROM students WHERE RollNo LIKE '%").append(keyword).append("%'"); QSqlQuery query = db.exec(queryString); while(query.next()) { list.append(Student(query.value(0).toString(), query.value(1).toString(), query.value(2).toString(), query.value(3).toString(), query.value(4).toString(), query.value(7).toInt())); } db.close(); return list; } }
int main(int argc, char *argv[]) { totalStudents = atoi(argv[1]); inOffice = atoi(argv[2]); int i; Professor(); for(i = 0 ; i < totalStudents; i++) { Student(i); } pthread_exit(NULL); }
void addStudent(Student st[], int &nrOfStudents){ string name; string program; int phoneNumber; int dateOfBirth; cout << "Enter name: "; getline(cin,name); cout << "Enter program: "; getline(cin,program); cout << "Enter phone number: "; cin >> phoneNumber; cout << "Enter date of birth: "; cin >> dateOfBirth; st[nrOfStudents] = Student(name, program, phoneNumber, dateOfBirth); nrOfStudents++; }
/******************************************************************************************************************************************************* Function Name: DeleteStudent() Purpose: delete a student In Parameters: None out parameters: NONE Version: 1 Author: Lovejot Singh ********************************************************************************************************************************************************/ bool DBManager::DeleteStudent(){ int id ; //temporary int to store user input bool found=false; // to check if user enter id was matched cout<<"Please enter the id of the student to delete "; cin>>id; for(int loop=0; loop <max ;loop++){ //for loop to find student of the id enter by user if(Students[loop].GetID()==id){ Students[loop]=Student("","","",-1); // change id to -1 set it out of scope found=true; cout<<"Student Deleted !\n"<<endl; return true; } } if(!found){cout<<"Student not found ! Please try again with correct ID !\n";} //if the id didn't match let the user Know return true; }
void Classroom::ModifySide() { students_[0][0] = Student({RIGHT, DOWN}); // upper left students_[0][col_ - 1] = Student({LEFT, DOWN}); // upper right students_[row_ - 1][0] = Student({UP, RIGHT}); // lower left students_[row_ - 1][col_ - 1] = Student({LEFT, UP}); // lower right for (IndexType col = 1; col < col_ - 1; col++) { students_[0][col] = Student({LEFT, DOWN, RIGHT}); // upside students_[row_ - 1][col] = Student({LEFT, UP, RIGHT}); // below } for (IndexType row = 1; row < row_ - 1; row++) { students_[row][0] = Student({UP, RIGHT, DOWN}); // left side students_[row][col_ - 1] = Student({UP, LEFT, DOWN}); // right side } }
int main(int argc, char* argv[]) { Student cheolsu(550001, "철수", "근처", 97); Student younghee(550002, "영희", "먼곳", 100); std::vector<Student> stu_list; stu_list.push_back( cheolsu); stu_list.push_back( younghee); stu_list.push_back( Student(550003, "만수","어중간한 곳", 87)); for( std::vector<Student>::const_iterator it = stu_list.begin() ; it != stu_list.end() ; ++it) { std::cout<<"Name : "<< it->getName() << " Address : "<<it->getAddress()<<" Score : "<<it->getScore()<<std::endl; } return 0; }
/****************************************************************************************************************************************************** Function Name: ReportStudentsOrdered() Purpose: Prints the students in alphabetic order of their last name In Parameters: None out parameters: NONE Version: 1 Author: Lovejot Singh ********************************************************************************************************************************************************/ bool DBManager::ReportStudentsOrdered(){ bool notempty=false; Student temp= Student(); int studs=0; // total number of students in the database for(int loop=0;loop<max;loop++){ if(Students[loop].GetID()!=-1){ studs=loop; //maximum number of studs in database notempty=true; // the database in not emtpy } } if(notempty){ // the database is not empty bool swap=false; // swap boolean to keep track of swaping taking place in buble sort Student buble[max+1]; // temp buble array to hold student for buble sorting for(int loop =0;loop<=studs;loop++){ //for loop to copy array buble[loop]=Students[loop]; //assigning array by index } while(swap!=true){ //while the array is not swaped swap=true; //set boolean value to true for(int loop=0;loop<studs;loop++){ //buble sort algorithm if(buble[loop+1].GetID() !=-1) if(buble[loop] > buble[loop+1] ){ temp=buble[loop+1]; buble[loop+1]=buble[loop]; buble[loop]=temp; swap=false; //swap occured turn boolean to false and let the loop run once again } } } //printing students order by last name for(int loop=0;loop<=studs;loop++){ if(buble[loop].GetID()!=-1) cout<<buble[loop]; } } else { cout<<"Database is empty ! "<<endl; } return true; }
int main(int argc, char **argv) { std::string name; vector<Student> students; int sum = 0; for (int i = 1; i < argc; ++i) { istream in(argv[i]); while (in >> name) { int mark; students.push_back(Student(name, argv[i])); auto it = students.end() - 1; in >> mark; while (mark != 0) { it->marks.push_back(mark); it->sum += mark; } sum += (double)it->sum / it->marks.size(); } } }
void InsertStudent::go() { string ID = getStuIDFromInput(); if(!db.doInsertStudent(Student(ID))) { cout << "Student already exist" << endl << endl; return; } string name = getStuNameFromInput(); unsigned int year = getStuYearFromInput(); char gender = getStuGenderFromInput(); if(db.doModifyStudent(ID, name, year, gender)) cout << "Creation of student record successful" << endl << endl; else db.doDeleteStudent(ID); return; }
/******************************************************************************************************************************************************* Function Name: AddNewStudent() Purpose: takes firstname , lastname , comment and fee from the user and add the student to the first available index of the array with id one greater than of a student before. For the first student it gives an id of 0 . In Parameters: None out parameters: return true Version: 3 Author: Lovejot Singh ********************************************************************************************************************************************************/ bool DBManager::AddNewStudent(){ int index, loop, tempID=-1; //index used to find first available ,loop used in for loop , tempID is used to find the highest id of the array float fee=0; // fee used to take user input char fName[25]; // temporary array of chars to hold firtname char lName[25]; //temporary array of chars to hold lastname char tcomment[1000]; //temporary array of chars to hold comment bool labhgea=false; // labhgea is used to check if there is an empty slot in an array or not for(loop=0;loop<max;loop++){ //for loop to find the available index to add new student if(Students[loop].GetID()==-1 && !labhgea ){ // && !labhgea is used to make sure we add student at first available space in the array labhgea=true; //space found go true index=loop; // index found } } tempID=-1; for(int mas=0;mas<max;++mas){ //for loop to find the highest ID of the array if(tempID < Students[mas].GetID()){ tempID=Students[mas].GetID(); } } ++tempID; //increase the id if(labhgea == false){ // if no empty slot available cout<<"Database is already full !!"<<endl; return true; } // take inputs from the user cout<<"Please enter the new student first name (e.g. Barrack): "; cin>>fName; cout<<"Please enter the new student last name (e.g. Obama): "; cin>>lName; cout<<"Please enter the comment ( 1000 characters max ): "; cin.ignore(); cin.getline(tcomment,sizeof(tcomment)); Students[index]=Student(fName,lName,tcomment,tempID); //using overloaded assignment operator to assign the value return true; }
void InputHandler::parseFile() { // Declare string to analyze string line; // First line is the number of windows open getline(f, line); int totWindows = atoi(line.c_str()); GenQueue<Arrival> *genQueue = new GenQueue<Arrival>(); while (getline(f, line)) { // Second line is a clock tick int clockTick = atoi(line.c_str()); // Third line is how many students arrive getline(f, line); int numStuds = atoi(line.c_str()); // Following lines are how many minutes a student needs at the window Student *studArray; studArray = new Student[numStuds]; for (int i=0; i<numStuds; ++i) { getline(f, line); int minsNeeded = atoi(line.c_str()); studArray[i] = Student(minsNeeded); studAmt++; } // Create Arrival object Arrival *arrival = new Arrival(clockTick, numStuds, studArray); // Put arrival into queue genQueue->enqueue(arrival); } // Create Registrar object for statistics calculations registrar = new Registrar(totWindows, genQueue); }
/** * Helper method that deals with each line of the file load in. * * @param input * the input file. * @return * A vector of Student objects to be inserted to the linked list. */ vector<Student> fileInputAndOutput::getLineFromFile(ifstream& input) { vector<string> stringVector; vector<Student> studentVector; string line; while (getline(input, line)) { char delimiter = ','; stringVector = this->split(line, delimiter); int grade = atof(stringVector[3].c_str()); stringVector[0] = this->stringToLower(stringVector[0]); stringVector[1] = this->stringToLower(stringVector[1]); Student currentStudent = Student(stringVector[0], stringVector[1], stringVector[2], grade, 0, 0); studentVector.push_back(currentStudent); } return studentVector; }
int main(){ srand(time(0)); int facultyCount = rand() % 2000 + 1000; //average 2500 faculty int studentCount = facultyCount * 5 + rand() % 1000 - rand() % 1000; //average 12.5k students int organizationCount = studentCount / 25 + rand() % 200 - rand() % 200;//average 500 organizations int courseCount = facultyCount / 5; //average 500 courses offered cout<<facultyCount<<" Faculty\n"<<studentCount<<" Students \n"<<organizationCount<<" Groups\n"<<courseCount<<" Courses\n"; //create our base objects for the university cout<<"Hiring Faculty..."<<endl; for(int i = 0; i < facultyCount; i++){ faculty.push_back(Faculty()); } cout<<"Accepting Student Applications..."<<endl; for(int i = 0; i < studentCount; i++){ students.push_back(Student()); } cout<<"Founding Organizations..."<<endl; for(int i = 0; i < organizationCount; i++){ organizations.push_back(Organization()); } cout<<"Designing Curriculum..."<<endl; unordered_set<string> uniqueCourses; //the set stores only unique values and determines duplicates in O(1) time. This is how we keep from regenerating the same class twice for(int i = 0; i < courseCount; i++){ Class newClass; string key; do{ newClass = Class(); //regenerate a class if it already exists key = newClass.subject + itos(newClass.number); }while(uniqueCourses.find(key) != uniqueCourses.end()); //loop until we fail to find a course with this key value. then we'll know it's unique uniqueCourses.insert(uniqueCourses.begin(), key); courses.push_back(newClass); } //create relations between these base objects (a.k.a the hard part). cout<<"Opening Registration & Open House..."<<endl; for(int i = 0; i < studentCount; i++){ for(int j = 0; j < (rand() % 20)+1; j++){//average 10 enrollments over the course of 4 semesters enrollment.push_back(EnrolledIn(students[i])); } for(int j = 0; j < rand() % 4; j++){ //up to 3 memberships per student membership.push_back(MemberOf(students[i])); } } cout<<"Assigning Professors..."<<endl; for(int i = 0; i < facultyCount; i++){ for(int j = 0; j < rand() % 4; j++){ //faculty can teach up to 3 courses instruction.push_back(Teaches(faculty[i])); } } cout<<"Volunteering Faculty to Organizations..."<<endl; for(int i = 0; i < organizationCount; i++){ if(rand() % 5 == 0) leadership.push_back(Leads()); //a quarter of organizations have faculty leadership } cout<<"Checking constraints..."<<endl; for(int i = 0; i < courseCount; i++){ if(courses[i].size == 0){ cout<<"Empty course fixed\n"; enrollment.push_back(EnrolledIn(&courses[i])); } if(!courses[i].hasProf){ cout<<"Untaught course fixed\n"; instruction.push_back(Teaches(&courses[i])); } } for(int i = 0; i < organizationCount; i++){ if(organizations[i].size == 0){ cout<<"Empty organization fixed\n"; membership.push_back(MemberOf(&organizations[i])); } } cout<<"Writing data to file...\n"<<endl; //self explanatory vvvvvv openFile(); for(int i = 0; i < facultyCount; i++){ writeFaculty(faculty[i].ID, faculty[i].name, faculty[i].salary); } for(int i = 0; i < studentCount; i++){ writeStudent(students[i].UIN, students[i].name, students[i].major, students[i].advisorID); } for(int i = 0; i < organizationCount; i++){ writeStudentOrganization(organizations[i].ID, organizations[i].name, organizations[i].category); } for(int i = 0; i < courseCount; i++){ writeCourse(courses[i].subject, courses[i].number, courses[i].hours, courses[i].title); } for(int i = 0; i < enrollment.size(); i++){ writeEnrolledIn(itosem(enrollment[i].semester), enrollment[i].subject, enrollment[i].number, enrollment[i].UIN, itograde(enrollment[i].grade)); } for(int i = 0; i < instruction.size(); i++){ writeTeaches(instruction[i].subject, instruction[i].number, instruction[i].facultyID, itosem(instruction[i].semester)); } for(int i = 0; i < leadership.size(); i++){ writeLeads(leadership[i].facultyID ,leadership[i].studentOrgID, itos(leadership[i].joinedMo)+"/"+itos(leadership[i].joinedYr)); } for(int i = 0; i < membership.size(); i++){ writeMemberOf(membership[i].UIN, membership[i].studentOrgID, itos(membership[i].joinedMo)+"/"+itos(membership[i].joinedYr)); } closeFile(); cout<<"All data generated"<<endl; }
#include "Student.h" Student std1 = Student("201424546", "AA", "g", 14, 85); Student std2 = Student("201424547", "AB", "ge", 14, 85); Student std3 = Student("201424548", "AC", "ge", 14, 85); Student std4 = Student("201424549", "AD", "gey", 14, 85); Student std5 = Student("201424550", "AE", "geyo", 14, 85); Student std6 = Student("201424551", "AF", "geyon", 14, 85); Student std7 = Student("201424552", "AG", "geyong", 14, 85); Student std8 = Student("201424553", "AH", "geyongn", 14, 85); Student std9 = Student("201424554", "AI", "geyongna", 14, 85); Student std10 = Student("201424555", "AJ", "geyongnam", 14, 85); Student std11 = Student("201424556", "AK", "geyongnama", 14, 85); Student std12 = Student("201424557", "AL", "geyongnamaa", 14, 85); Student std13 = Student("201424558", "AM", "geyongnamaaa", 14, 85); Student std14 = Student("201424559", "AN", "geyongnamaaaa", 14, 85); Student std15 = Student("201424560", "AO", "geyongnamaaaaa", 14, 85); Student std16 = Student("201424561", "AP", "geyongnamas", 14, 85); Student std17 = Student("201424562", "AQ", "geyongnamasd", 14, 85); Student std18 = Student("201424563", "AR", "geyongnamasdf", 14, 85); Student std19 = Student("201424564", "AS", "geyongnamb", 14, 85); Student std20 = Student("201424565", "AT", "geyongnambb", 14, 85); Student std21 = Student("201424566", "AU", "geyongnambbb", 14, 85); Student std22 = Student("201424567", "AV", "geyongnambbbb", 14, 85); Student std23 = Student("201424568", "AW", "geyongnambbbbb", 14, 85); Student std24 = Student("201424569", "AX", "geyongnamc", 14, 85); Student std25 = Student("201424570", "AY", "geyongnamcc", 14, 85); Student std26 = Student("201424571", "AZ", "geyongnamccc", 14, 85); Student std27 = Student("201424572", "BA", "geyongnamcccc", 14, 85); Student std28 = Student("201424573", "BB", "geyongnamccccc", 14, 85); Student std29 = Student("201424574", "BC", "geyongnamccc", 14, 85);
//this function takes the command from the cmd into commands that the program knows void ParseCommand(Command cmd, std::vector<std::string> payload) { if (cmd == Invalid) { printMessage("Invalid command."); } //adds a student else if (cmd == Add) { //Add a student if (payload.size() != 6) { //bad news throw the user an error. printMessage("Command add recieved incorrect # of arguments."); } else { //constuct the student Student toAdd = Student(payload[0], payload[1], payload[2], std::stoi(payload[3]), std::stoi(payload[4]), std::stoi(payload[5])); //make sure that id dosent exsist std::vector<Student> toCheck = students.searchStudents(students.ID, toAdd.getUID()); //if to check == 0 then student doesnt exsist if (toCheck.size() < 100) { //make sure the student is valid if (!toAdd.isValidStudent()) { printMessage("Invalid student attribute."); return; } //add students.addStudent(toAdd); students.saveStudent(); std::cout << toAdd.getName() + " successfully added" << std::endl; } else { std::cout << "Student already exists" << std::endl; } } } //remove a student else if (cmd == Remove) { //see if student exsists std::vector<Student> toCheck = students.searchStudents(students.ID, payload[0]); //see if student exsist if (toCheck.size() != 0) { std::cout << "Student does not exist." << std::endl; } else { //delete student students.deleteStudent(toCheck[0]); students.saveStudent(); std::cout << "Student deleted successfully" << std::endl; } } //search for student else if (cmd == Search) { //make sure there are arguments if (payload.size() == 0) { std::cout << "Printing all students:" << std::endl; students.printAllStudents(); return; } else { //slit the payload std::vector<std::string> commands = fileIO::split(payload[0], '='); //make sure the format is correct if (commands.size() < 2) { printMessage("Search argument recieved invalid. Format should be [email protected]."); } else { Students queryList = Students(students.searchStudents(commands[0],commands[1])); //iterate through rest of the arguments for (int i = 1; i < payload.size(); i++) { std::vector<std::string> commands = fileIO::split(payload[i], '='); if (commands.size() != 2) { printMessage("Search argument recieved invalid. Format should be [email protected]."); } queryList = queryList.searchStudents(commands[0], commands[1]); } queryList.printAllStudents(); } } } //update the student else if (cmd == Update) { //search for the student std::vector<Student> tempStudents = students.searchStudents(Students::ID, payload[0]); //for each argument update that one for (int i = 1; i < payload.size(); i++) { std::vector<std::string> commands = fileIO::split(payload[i], '='); students.updateInfo(tempStudents[0], commands); } students.saveStudent(); } //you need help so print it else if (cmd == Help) { std::cout << "Here are a list of all the example commands: " << std::endl; std::cout << "add <name>,<UID>,<email>,<firstscore>,<secondscore>,<thirdscore>" << std::endl; std::cout << "remove <UID>" << std::endl; std::cout << "search UID=<id>,name=<bob>" << std::endl; std::cout << "update <UID>,UID=<id>,name=<new name>" << std::endl; } }