当前位置: 首页>>代码示例>>C++>>正文


C++ Students::updateInfo方法代码示例

本文整理汇总了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;
	}
}
开发者ID:darkensoul,项目名称:SW-Testing,代码行数:101,代码来源:SoftwareTesting.cpp


注:本文中的Students::updateInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。