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


C++ Course::getId方法代码示例

本文整理汇总了C++中Course::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ Course::getId方法的具体用法?C++ Course::getId怎么用?C++ Course::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Course的用法示例。


在下文中一共展示了Course::getId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateCourse

void FileStorage::updateCourse(Course c){
	string search_string = to_string(c.getId());
	string replace_string = search_string + " " + c.getName() + " " + c.getDescription() + " ";
	for (vector<string>::size_type i = 0; i != c.getPreCourses().size(); i++) {
		replace_string += c.getPreCourses()[i] + " ";
	}
	replace_string += " $ " + to_string(c.getMaxStudents()); 

	string inbuf;
	fstream input_file(this->file_name, ios::in);
	ofstream output_file("result.txt");
	//Check for Error
	if (input_file.fail()){
		cerr << "Error Opening Data File";
		exit(1);
	}
	while (!input_file.eof()){
		getline(input_file, inbuf);

		int spot = inbuf.find(search_string);
		if (spot >= 0){
			string tmpstring = inbuf.substr(0, spot);
			tmpstring += replace_string;
			tmpstring += inbuf.substr(spot + inbuf.length(), inbuf.length());
			inbuf = tmpstring;
		}

		output_file << inbuf << endl;
	}
	input_file.close();
	output_file.close();

	int result;
	char oldname[] = "result.txt";
	char newname[] = "data.txt";
	remove(newname);
	result = rename(oldname, newname);
	if (result == 0)
		puts("File successfully updated\n");
	else
		perror("Course update error: Error renaming file\n");
}
开发者ID:RafaelBar,项目名称:CourseBid,代码行数:42,代码来源:file_storage.cpp

示例2: displayAllAvailableCourses

// check if course is valid and show it in the screen
int displayAllAvailableCourses(SeasonConfig & seasonConfig, Course & course) {
	system("cls");
	bool print;
	int count = 0;
	cout << "List of courses : \n\n";
	for (int i = 0; i < seasonConfig.courses.count(); i++) {
		print = true;
		for (int j = 0; j < course.pre.count(); j++) {
			if (seasonConfig.courses.get(i).getId() == course.pre.get(j).getId()) {
				print = false;
			}

		}
		if (print && seasonConfig.courses.get(i).getId() != course.getId()) {
			count++;
			cout << i << ": " << seasonConfig.courses.get(i).name.get() << endl;
		}

	}
	cout << endl << endl << endl;
	return count;
}
开发者ID:uriel87,项目名称:CourseBid,代码行数:23,代码来源:CourseEditingState.cpp

示例3: writeCourse

/**
 * Write a course file.
 * @param course A Course.
 * @param file_path The target file path.
 * @throw FileException, XmlException
 */
void writeCourse(const Course& course, const QString& file_path)
{
	QFile output(file_path);
	if (!output.open(QIODevice::WriteOnly))
	{
		throw FileException("Cannot open file for writing", output.fileName());
	}

	QXmlStreamWriter writer(&output);
	writer.setAutoFormatting(true);
	writer.setAutoFormattingIndent(1);

	writer.writeStartDocument();

	writer.writeStartElement("course");

	writer.writeStartElement("id");
	writer.writeCharacters(course.getId().toString());
	writer.writeEndElement();

	writer.writeStartElement("title");
	writer.writeCharacters(course.getTitle());
	writer.writeEndElement();

	writer.writeStartElement("description");
	writer.writeCharacters(course.getDescription());
	writer.writeEndElement();

	writer.writeStartElement("keyboardLayout");
	// TODO: Add keyboardLayout
	writer.writeEndElement();

	writer.writeStartElement("lessons");
	for (const auto& it :course)
	{
		writer.writeStartElement("lesson");

		writer.writeStartElement("id");
		writer.writeCharacters(it->getId().toString());
		writer.writeEndElement();

		writer.writeStartElement("title");
		writer.writeCharacters(it->getTitle());
		writer.writeEndElement();

		writer.writeStartElement("newCharacters");
		writer.writeCharacters(it->getNewChars());
		writer.writeEndElement();

		writer.writeStartElement("text");
		writer.writeCharacters(it->getText());
		writer.writeEndElement();

		writer.writeEndElement(); // </lesson>
	}
	writer.writeEndElement(); // </lessons>

	writer.writeEndElement(); // </course>

	writer.writeEndDocument();
}
开发者ID:mNisblee,项目名称:QTouch,代码行数:67,代码来源:writer.cpp


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