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


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

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


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

示例1: print

// Prints all the information about the student object
void Student::print(){
     cout << ID << "\t\t" << firstname << "\t\t" << lastname << endl;
     
     if( courses.getLength() == 0 ){
     }else
     {
          cout << endl << "\tEnrolled Courses: " << endl;
          cout << "\tCourse ID\tCourse Name\n";
          for( int i=1; i<=courses.getLength(); i++ ){
               Course c;
               courses.retrieve(i,c);
               c.print();
          }
          cout << endl << endl;
     }
}
开发者ID:selinguldamlasioglu,项目名称:Registration-System,代码行数:17,代码来源:Student.cpp

示例2:

void 
print_list()
{
	int i;
	const LinkedList &sList = master_student_list();  //local reference to student list.
	const LinkedList &cList = master_course_list();	  //local reference to course list.
	Student *studentPtr;  // local pointer to student object
	Course *coursePtr;	  // local pointer to course object
	
	if (sList.size() <= 0)  // Attempts to acces an empty list are avoided.
		cerr << "\n*** No Students in the List ***\n" << endl;
		
	if (sList.size() > 0)
	{
		cout << "\nSTUDENTS CURRENTLY IN THE DATABASE" << endl;
		// Print out the student objects.
		for (i = 0; i < sList.size(); i++)
		{
			// Get a student object from the list
			studentPtr = (Student*)sList[i]; // uses operator overloading for '[]'
	
			// Now print the student using the print behaviour of the student object.
			studentPtr->print();
		}
	}

	if (cList.size() <= 0)  // Attempts to acces an empty list are avoided.
		cerr << "\n*** No Courses in the List ***" << endl;

	if (cList.size() > 0)
	{
		cout << "ENROLLMENT FOR ALL COURSES IN THE DATABASE\n" << endl;
		// Print out the course objects.
		for (i = 0; i < cList.size(); i++)
		{
			// Get a course object from the list
			coursePtr = (Course*)cList[i];

			// Now print the course using the print behaviour of the course object.
			coursePtr->print();
		}
	}
}
开发者ID:malachig,项目名称:archive,代码行数:43,代码来源:main.cpp

示例3: main

int main()
{
	//default course
	Course course;
	Student* pStudent1;
	Student student1("yifat",12292);
	Student student2("yifatush",12292);
	cout<<"Default course : "<<endl;
	course.print();
	cout<<"find not exist student expected -1 ---> actual result "<<course.findStudent(23423)<<endl;
	cout<<"find invalid student expected -1 ---> actual result "<<course.findStudent(234233)<<endl;
	cout<<"find student exist in first cell expected 0 ---> actual result "<<course.findStudent(DEFAULT_ID_1)<<endl;
	course.print();
	cout<<"add invalid student id and print --->stay the same"<<endl;
	course.addStudent(456456);
	course.print();
	cout<<"add already exist student and print ---> stay the same"<<endl;
	course.addStudent(DEFAULT_ID_1);
	course.print();
	cout<<"add valid student and print ---> new student added to the course"<<endl;
	course.addStudent(12346);
	course.print();
	cout<<"remove student and print ---> student removed from the course"<<endl;
	course.removeStudent(12346);
	course.print();
	cout<<"remove student that not in the course and print ---> student list stay the course"<<endl;
	course.removeStudent(12346);
	course.print();
	cout<<"switch between students that not in the course and print ---> student list stay the course"<<endl;
	course.switchStudents(12346,12222);
	course.print();
	cout<<"switch between the same student in the course and print ---> student list stay the course"<<endl;
	course.switchStudents(DEFAULT_ID_2,DEFAULT_ID_2);
	course.print();
	cout<<"switch between one student in the course and the other not and print ---> student list stay the course"<<endl;
	course.switchStudents(DEFAULT_ID_1,12346);
	course.print();
	cout<<"switch between 2 students in the course and print ---> students order changed"<<endl;
	course.switchStudents(DEFAULT_ID_1,DEFAULT_ID_2);
	course.print();
	cout<<"switch again between 2 students in the course and print ---> students order return to prev order"<<endl;
	course.switchStudents(DEFAULT_ID_1,DEFAULT_ID_2);
	course.print();
	cout<<"get for not exist student expected null--->actual result ";
	if(course.getStudent(12346)==NULL)
		cout<<"NULL"<<endl;
	cout<<"get for exist student expected different from null--->actual result ";
	if(course.getStudent(DEFAULT_ID_1)!=NULL) {
		(*course.getStudent(DEFAULT_ID_1)).print();
	}
	pStudent1 = (course.getStudent(DEFAULT_ID_1));
	(*pStudent1).addGrade(12);
	cout<<"add grade to student via getStudent"<<endl;
	course.print();
	cout<<"init course with 2equal pointers--->course with 1 student"<<endl;
	Course course2(pStudent1, pStudent1);
	course2.print();
	cout<<"Check is equal expected result false---->"<<boolalpha<<course.isEqual(DEFAULT_ID_1,DEFAULT_ID_2)<<endl;
	cout<<"Check is equal expected result true---->"<<boolalpha<<course.isEqual(DEFAULT_ID_2,DEFAULT_ID_1)<<endl;
	cout<<"Check is equal expected result true---->"<<boolalpha<<course.isEqual(DEFAULT_ID_2,DEFAULT_ID_2)<<endl;
	cout<<"create course is 2 equal student----> only 1 student in the course"<<endl;
	Course course4(NULL, NULL);
	Course course3(student1, student2);
	course3.print();
	cout<<"course init with null pointer expected as default course"<<endl;
	course4.print();
	course3.addStudent(11223);
	course3.addStudent(11224);
	course3.addStudent(11225);
	course3.addStudent(11226);
	cout<<"add students "<<endl;
	course3.print();
	course3.removeStudent(11224);
	course3.removeStudent(11227);
	course3.removeStudent(student1.getId());
	cout<<"after remove:"<<endl;
	course3.print();
	cout<<"find student 11226 enter student "<<boolalpha<<(course3.findStudent(11226)!=NOT_EXIST)<<endl;
	cout<<"get the 11226 student "<<endl;
	(*course3.getStudent(11226)).print();
	(*course3.getStudent(11226)).SetName("New name");
	cout<<"Set name of student 11226:"<<endl;
	course3.print();

	//Test student
	cout<<"student without name default name :";
	Student noName("",12345);
	noName.print();
	cout<<"student with invalid name default values :";
	Student noName1("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12345);
	noName1.print();
	cout<<"student with invalid id min length default values :";
	Student invalidId("yifat",1234);
	invalidId.print();
	cout<<"student with invalid id max length default values :";
	Student invalidIdMax("yifat",123444);
	invalidIdMax.print();
	cout<<"student with invalid id no digit default values :";
	Student invalidIdDigit("yifat","h12hh");
	invalidIdDigit.print();
//.........这里部分代码省略.........
开发者ID:yifatBi,项目名称:coursesSystem,代码行数:101,代码来源:main.cpp


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