本文整理汇总了C++中Students::updateInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ Students::updateInfo方法的具体用法?C++ Students::updateInfo怎么用?C++ Students::updateInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Students
的用法示例。
在下文中一共展示了Students::updateInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseCommand
//.........这里部分代码省略.........
//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;
}
}