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


C++ Student::getAge方法代码示例

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


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

示例1:

// setFirst
TEST(StudentClass, STUDENT_CLASS_5) {
  const char *first = "";
  const char *ssn = "";

  const char *text_short = "1234567890";
  const char *text_long = "123456789012345678901234567890123456789012345678901234567890123";
  const char *text_long1 = "1234567890123456789012345678901234567890123456789012345678901234";
  const char *text_long2 = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";

  Student s;

  EXPECT_EQ(s.getAge(), 0);
  EXPECT_EQ(s.getLast(), (void *)0);
  EXPECT_EQ(s.getFirst(), (void *)0);
  EXPECT_EQ(s.getEmail(), (void *)0);
  EXPECT_EQ(std::strcmp(s.getSsn(), ssn), 0);

  s.setFirst(text_short);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_short), 0);
  s.setFirst(first);
  EXPECT_EQ(std::strcmp(s.getFirst(), first), 0);
  s.setFirst(text_long);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_long), 0);
  s.setFirst(0);
  EXPECT_EQ(s.getFirst(), (void *)0);
  s.setFirst(text_long1);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_long1), 0);
  s.setFirst(text_long2);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_long2), 0);
  s.setFirst(text_short);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_short), 0);
  s.setFirst(0);
  EXPECT_EQ(s.getFirst(), (void *)0);
}
开发者ID:kdawgwilk,项目名称:school,代码行数:35,代码来源:1_student_class_tests.cpp

示例2: s

// assignment operator
TEST(StudentClass, STUDENT_CLASS_14) {
  const int  age = 1;
  const char *last = "a";
  const char *first = "b";
  const char *email = "c";
  const char *ssn = "999-99-9999";
  const Student s(age, last, first, email, ssn);

  EXPECT_EQ(s.getAge(), age);
  EXPECT_EQ(std::strcmp(s.getLast(), last), 0);
  EXPECT_EQ(std::strcmp(s.getFirst(), first), 0);
  EXPECT_EQ(std::strcmp(s.getEmail(), email), 0);
  EXPECT_EQ(std::strcmp(s.getSsn(), ssn), 0);

  Student t;

  t = s;

  EXPECT_EQ(t.getAge(), age);
  EXPECT_EQ(std::strcmp(t.getLast(), last), 0);
  EXPECT_EQ(std::strcmp(t.getFirst(), first), 0);
  EXPECT_EQ(std::strcmp(t.getEmail(), email), 0);
  EXPECT_EQ(std::strcmp(t.getSsn(), ssn), 0);

  EXPECT_NE(t.getLast(), s.getLast());
  EXPECT_NE(t.getFirst(), s.getFirst());
  EXPECT_NE(t.getEmail(), s.getEmail());
  EXPECT_NE(t.getSsn(), s.getSsn());
}
开发者ID:kdawgwilk,项目名称:school,代码行数:30,代码来源:1_student_class_tests.cpp

示例3: checkTeam

bool Team::checkTeam() const {

    Student* student;
    int age;
    University* studentUniversity;

    int captainCount = 0;
    int studentCount = 0;
    float totalAge = 0;

    cout << "HELLO" << endl;

    for (int i=0; i<4; i++){
        student = students[i];

        if (student == 0){
            continue;
        }

        cout << student->getName() << endl;

        studentCount += 1;

        age = student->getAge();
        if ((age < 18) || (age > 40)){
            return false;
        }

        totalAge += (float) age;

        if (student->getCaptain()){
            captainCount++;
        }

        studentUniversity = &student->getUniversity();

        if (studentUniversity == 0){
            return false;
        }

        if (*studentUniversity != *university){
            return false;
        }

    }

    if (captainCount != 1) return false;
    if (studentCount != 4) return false;
    if (totalAge/4 > 24) return false;

    return true;

}
开发者ID:giblets2570,项目名称:m1-program-design,代码行数:53,代码来源:Team.cpp

示例4: AddStudents

void AcademyGroup::AddStudents(Student & add){
	if (count % sizof == 0 && count != 0){
		Student **pStTemp = new  Student*[count + sizof]; if (!pStTemp) { exit(0); }
		int i;
		for (i = 0; i < count; i++){
			pStTemp[i] = pSt[i];
		}
		delete[] pSt;
		pSt = pStTemp;
		for (; i < count + sizof; i++){
			pSt[i] = new Student; if (!pSt[i]) { exit(0); }
		}
	}
	delete pSt[count];
	pSt[count] = new Student(add.getName(), add.getSurname(), add.getAge(), add.getPhone(), add.getAverage()); if (!pSt[count]) { exit(0); }
	count++;
}
开发者ID:IgorVi,项目名称:AcademyGroup,代码行数:17,代码来源:AcademyGroup.cpp


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