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


C++ Students类代码示例

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


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

示例1: TEST

TEST(AddPhoneNumber, AddPhoneNumberTest2){
  Students* students = new Students();
  students->addPhoneNumbers(0, "fsadhfdkasdfhl");
  students->addPhoneNumbers(0, "801");
  students->addUser("Hi", 0);
  EXPECT_EQ("801", students->phoneForName("Hi"));

}
开发者ID:cincospenguinos,项目名称:CS3505,代码行数:8,代码来源:StudentsTests.cpp

示例2: main

int main(int argc, char *argv[])
{
	SetConsoleTitle(TEXT("Students" ));
	// declaration of new variables
	string st_name,st_last_name;
	int final_scores[5] = {4,4,5,5,5};
	float average_ball;

	cout << "Enter Student name: ";
	cin >> st_name;
	cout << "Enter Student last name: ";
	cin >> st_last_name;
	Students *Student = new Students(st_name,st_last_name);
	cout << "Enter Student scores: ";
	for (int i=0;i<5;i++)
	{
		cin >> final_scores[i];
	}

	Student->set_student_name(st_name);
	Student->set_student_last_name(st_last_name);
	Student->set_student_score(final_scores);
	average_ball = Student->calculate_average_ball(final_scores);

	cout << "Current profile of student: " << endl;
	cout << Student->get_student_name() << endl;
	cout << Student->get_student_last_name() << endl;
	cout << Student->get_average_ball() << endl;
	cout << endl;
	Student->show_scores();
	cout << "Saving current profile to file..." << endl;
	Student->save_profile();
	delete Student;
	system("pause");
	return EXIT_SUCCESS;
}
开发者ID:Macleopard,项目名称:MyProjects,代码行数:36,代码来源:main.cpp

示例3: main

int main(int argc, char* argv[])
{
	students.loadStudents();

	std::cout << "Welcome to the student catalog thing" << std::endl;
	while (true)
	{
		std::cout << "Input a command:" << std::endl;
		std::string toPass = "";
		std::getline(std::cin, toPass);

		if (toPass == "exit")
		{
			break;
		}

		ParseStringToCommand(toPass);
	}
	return 0;
}
开发者ID:darkensoul,项目名称:SW-Testing,代码行数:20,代码来源:SoftwareTesting.cpp

示例4: _tmain

int _tmain(int argc, char* argv[])
{
	students.loadStudents();

	std::cout << "Welcome to the student catalog thing" << std::endl;
	while (true)
	{
		std::cout << "Input a command:" << std::endl;
		std::string toPass = "";
		std::getline(std::cin, toPass);

		if (toPass == "exit")
		{
			break;
		}

		switch (VerifyInputIntegrity(toPass))
		{
			case None:
				ParseStringToCommand(toPass);
				break;
			case InvalidCharacter:
				std::cout << "Invalid chracter in input" << std::endl;
				break;
			case InvalidFormat:
				std::cout << "Invalid format detected" << std::endl;
				break;
			default:
				std::cout << "Unknown error" << std::endl;
				break;
		}

		
	}
	return 0;
}
开发者ID:AlcesAlces,项目名称:SoftwareTesting,代码行数:36,代码来源:SoftwareTesting.cpp

示例5: main

int main(int argc, char* argv[]) {
    ifstream file;
    string data;
    vector<string> tokens;
    Courses courses;
    Students students;

    file.open("courses.conf");
    if (!file.is_open()) {
        cout << "Failed opening courses.conf." << endl;
        return 0;
    }
    while (getline(file, data)) {
        tokens = str_split(data, ',');
        // data: WEEKDAY,COURSE-ID,SPACE
        Course* course = new Course(*(tokens[0].c_str()) - '0', 
                                    tokens[1], 
                                    atoi(tokens[2].c_str()));
        courses.push_back(course);
    }
    file.close();

    file.open("students.conf");
    if (!file.is_open()) {
        cout << "Failed opening students.conf." << endl;
        return 0;
    }

    while (getline(file, data)) {
        tokens = str_split(data, ',');

        // data: STUD-ID,COURSE-ID1,COURSE-ID2,...,COURSE-IDN
        Student* student = new Student(tokens[0]);
        if (tokens.size() > 1) {
            for (size_t i = 1; i < tokens.size(); ++i) {
                for (size_t j = 0; j < courses.size(); ++j) {
                    if (courses[j]->getCourseId() == tokens[i]) {
                        if (courses[j]->addStudent(student)) {
                            // we have found a room for this student
                            // in the course he requested, so we are breaking
                            // the search for room.
                            // NOTE: we are not break;'ing when we find 
                            // a matching course because there might be 
                            // room in another day for this course.
                            break;
                        }
                    }
                }
            }
        }

        students.push_back(student);
    }
    
    file.close();

    // clean output files
    ofstream output;
    output.open("courses.out");
    output.close();
    output.open("students.out");
    output.close();

    for (size_t i = 0; i < courses.size(); ++i) {
        courses[i]->print("courses.out");
    }

    for (size_t i = 0; i < students.size(); ++i) {
        students[i]->print("students.out");
    }

    for (size_t i = 0; i < courses.size(); ++i) {
        delete courses[i];
        courses[i] = 0;
    }

    for (size_t i = 0; i < students.size(); ++i) {
        delete students[i];
        students[i] = 0;
    }

    return 0;
}
开发者ID:dvirazulay,项目名称:homework,代码行数:83,代码来源:matrixU.cpp

示例6: SplitStudents

bool SplitStudents()
{
	ofstream ofs;
	ofs.open("log.txt");
	static int tmpMatrix[3][3] = { 0 };

	for (size_t i = 0; i < TypeNum; i++)
	{
		Students* pp = pStu[i];
		cout << "processing " << pp->GetName() << "..." << endl;

		for (size_t mi = 0; mi < 3; mi++)
		{
			tmpMatrix[mi][0] = copySubjectMatrix[mi][pp->m_s1];
			tmpMatrix[mi][1] = copySubjectMatrix[mi][pp->m_s2];
			tmpMatrix[mi][2] = copySubjectMatrix[mi][pp->m_s3];
		}

		//if (ofs.is_open())
		//{
		//	ofs << "processing " << pp->GetName() << "..." << endl;
		//	ofs << "original:" << endl;
		//	for (size_t mi = 0; mi < 3; mi++)
		//	{
		//		ofs << tmpMatrix[mi][0] << " " << tmpMatrix[mi][1] << " " << tmpMatrix[mi][2] << endl;
		//	}
		//	ofs << endl;
		//}

		int num = pp->m_stuNum;
		int index = 0;
		while (num > 0)
		{
			index = (rand() % 6);
			bool minusSuccess = false;
			for (size_t identityIndex = 0; identityIndex < 6; identityIndex++)
			{
				int ii = (index + identityIndex) % 6; // 不断变换单位矩阵

				// 检查根据当前单位矩阵是否有学生可以分
				bool hasStudent = true;
				for (size_t ri = 0; ri < 3; ri++)
				{
					hasStudent = true;
					for (size_t ci = 0; ci < 3; ci++)
					{
						if (identityMatrix[ii][ri][ci] == 1)
							hasStudent = tmpMatrix[ri][ci] > 0;
					}
					if (!hasStudent)
						break;
				}

				if (!hasStudent)
					continue;
				else
				{
					// 分学生
					for (size_t ri = 0; ri < 3; ri++)
					{
						for (size_t ci = 0; ci < 3; ci++)
						{
							if (identityMatrix[ii][ri][ci] == 1)
							{
								tmpMatrix[ri][ci]--;
								classes[ri][pp->GetSubject(ci)].Push(pp->GetName(), pp->m_stuNum - num); // 分学生
							}
						}
					}
					num--;
					minusSuccess = true;
					break;
				}
			}
			// 由于某个班级人数分完了导致分不了,此时需要调整班级人数来容纳新的学生
			// 这里可以通过添加班级人数的最大误差来限制人数
			if (!minusSuccess)
			{
				vector<pair<int, int>> tmpIndex; // 有些课时不排课(用-1表示),找出来
				for (size_t ii = 0; ii < 3; ii++)
				{
					for (size_t jj = 0; jj < 3; jj++)
					{
						if (tmpMatrix[ii][jj] == -1)
							tmpIndex.push_back(pair<int, int>(ii, jj));
					}
				}

				int iii = 0;
				for (iii = 0; iii < 6; ++iii)
				{
					int sum = 0;
					for (int jjj = 0; jjj < tmpIndex.size(); ++jjj)
					{
						sum += identityMatrix[iii][tmpIndex[jjj].first][tmpIndex[jjj].second];
					}
					if (sum == 0)
						break;
				}

//.........这里部分代码省略.........
开发者ID:qqchen,项目名称:paike,代码行数:101,代码来源:main.cpp

示例7: ParseCommand

//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]");
//.........这里部分代码省略.........
开发者ID:darkensoul,项目名称:SW-Testing,代码行数:101,代码来源:SoftwareTesting.cpp

示例8: Register_Function

void Register_Function(Modules md, Students st)
{
	Students st;
	Modules md;
	int dd,mm,yyyy;
   bool done=1;
   bool done_d=1;
   char string_date[15];
   char ch_d,stat=2;
   while(done_d)
   {
     system("cls");
     cout<<"\n Enter the New date (E).";
     cout<<"\n Exit (Q) ";
	 cout<<"\n Enter your choice: ";

	 cin>>  ch_d;

	 switch(ch_d)
	 {
	 case 'q':
	 case 'Q':
     done_d=0;

	 stat=1;
	 break;

 	 case 'e':
	 case 'E':
     stat=0;
	 break;


     }

if(stat==1)
break;
else if(stat==2)
continue;


   system("cls");
   cout<<"Please Enter the Date(dd mm yyyy):";
   cin>>dd>>mm>>yyyy;
	while(done)
	{ int ID;
     md.Browse();
	 cout<<"\n Date(dd-mm-yyy):"<<dd<<"-"<<mm<<"-"<<yyyy;
	 cout<<"\n Please Select one of Modules by ID or -1 to exit: ";
	 cin>>  ID;
	
	 if (ID<=-1) {done=0;break;}
	  if(md.Check_ID(ID)==0)
	 {getch();
		 continue;
	 }
	 int done_m=1;
	 while(done_m)
	 {
     system("cls");
     cout<<"\n Date(dd-mm-yyy):"<<dd<<"-"<<mm<<"-"<<yyyy<<" Module Name: "<<md.Get_Name(ID);
     cout<<"\n Enter the student ID (I).";
	 //cout<<"\n Undo (U).";
	 //cout<<"\n Search student name by ID (S).";
     cout<<"\n Browse students(B).";
	 cout<<"\n Exit (Q) ";
	 cout<<"\n Enter your choice: ";

     char IDc; 
	 int done_i=1;
	 int IDi=0;
	 cin>>  IDc;

	 switch(IDc)
	 {
	 case 'q':
	 case 'Q':
     done_m=0;
	 break;

	 case 'i':
	 case 'I':
          //system("cls")

		 while(1){
cout<<"\n Date(dd-mm-yyy):"<<dd<<"-"<<mm<<"-"<<yyyy<<" Module Name: "<<md.Get_Name(ID);
cout<<"\n Enter Student ID (-1 to exit): ";
cin>>IDi;
if (IDi<0) break;
if (st.Check_ID(IDi))
{
     cout<<"\n Date(dd-mm-yyy):"<<dd<<"-"<<mm<<"-"<<yyyy<<" Module Name: "<<md.Get_Name(ID)<<" Student ID/Name: "<<IDi<<'/'<<st.Get_Name(IDi);
	

     cout<<"\n On Time (O).";
	 cout<<"\n Late (L).";
	 cout<<"\n Absent (A).";
     cout<<"\n Exit (Q) ";
	 cout<<"\n Status: ";
	 cin>>IDc;
//.........这里部分代码省略.........
开发者ID:alburaawi,项目名称:Academic-Projects,代码行数:101,代码来源:Register.cpp

示例9: main

int main()
{
    Teachers aTeacher;
    Students aStudent;
    GuestTeachers aGuestTeacher;

	int option = 0;
	int identity;
	int Points;
	if (Points < 0 || Points > 100)
    {
        cout << "Bad input! " << endl;
    }
	int EvaluationMark;
	if(EvaluationMark < 2 && EvaluationMark >6)
    {
        cout << "Bad input! " << endl;
    }
	int MonthlySalary;
	int passedDays;
	int SalaryForCourse;
	string Name;
	string Course;

	cout << "Get data for student with ID: 1" << endl;
	cout << "Get data for teacher with ID: 2" << endl;
	cout << "Get data for guest teacher with ID: 3" << endl;
	cout << "Add data for new student: 4" << endl;
	cout << "Add data for new teacher: 5" << endl;
	cout << "Add data for new guest	teacher: 6" << endl;

	unsigned short int arr[65535];

	while(true)
    {
        cout << "Enter option: ";
        cin >> option;
        {
            if(option == 7)
            {
                break;
            }
            if (option < 1 || option > 7)
            {
                cout << "Bad input! " << endl;
            }
            switch(option)
            {
            case 1:
                cout << aStudent.getID() << endl;
                cout << aStudent.getName() << endl;
                cout << aStudent.getCurrentCourse() << endl;
                cout << aStudent.getCurrentPoints() << endl;
                cout << aStudent.getAverageEvaluationMark() << endl;
                break;
            case 2:
                cout << aTeacher.getID() << endl;
                cout << aTeacher.getName() << endl;
                cout << aTeacher.getCurrentCourse() << endl;
                cout << aTeacher.getMonthlySalary() << endl;
                cout << aTeacher.getPassedDays() << endl;
                break;
            case 3:
                cout << aGuestTeacher.getID() << endl;
                cout << aGuestTeacher.getName() << endl;
                cout << aGuestTeacher.getCurrentCourse() << endl;
                cout << aGuestTeacher.getSalaryForCourse() << endl;
                break;
            case 4:
                cout << "Enter ID, Name, Current Course , Current Points and Average Evaliation Mark: "<< endl;
                cin >> identity >> Name >> Course >> Points >> EvaluationMark;
                aStudent.setID(identity);
                aStudent.setName(Name);
                aStudent.setCurrentCourse(Course);
                aStudent.setCurrentPoints(Points);
                aStudent.setAverageEvaluationMark(EvaluationMark);
                cout << "A student profile has been added." << endl;
                break;
            case 5:
                cin >> identity >> Name >> Course >> MonthlySalary >> passedDays;
                aTeacher.setID(identity);
                aTeacher.setName(Name);
                aTeacher.setCurrentCourse(Course);
                aTeacher.setMonthlySalary(MonthlySalary);
                aTeacher.setPassedDays(passedDays);
                cout << "A teacher profile has been added." << endl;
                break;
            case 6:
                cin >> identity >> Name >> Course >> SalaryForCourse;
                aGuestTeacher.setID(identity);
                aGuestTeacher.setName(Name);
                aGuestTeacher.setCurrentCourse(Course);
                aGuestTeacher.setSalaryForCourse(SalaryForCourse);
                cout << "A guest teacher profile had been added." << endl;
                break;
            }
        }
    }

	return 0;
//.........这里部分代码省略.........
开发者ID:kilarionov,项目名称:cppTopics,代码行数:101,代码来源:dom3+(1).cpp


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