Exemplo n.º 1
0
void Database::Search(string sType, string sValue){
                                                                               // simple but horribly inefficent search function
  bool foundValue = false;
  int size = Database::iTotalStudents;

  for(int i = 0; i < size; i++){

    Student newStudent = Student();
    newStudent = Database::getStudentOffArray(i);

    if(sType == "last"){
      if(newStudent.getLastName() == sValue){
	foundValue = true;
	cout <<"\nFound a match for " << sValue << endl;
	cout << newStudent;
      }//end if

    } else if (sType == "first"){

      if(newStudent.getFirstName() == sValue){
	foundValue = true;
	cout <<"\nFound a match for " << sValue << endl;
	cout << newStudent;
      }//end if

    } else if (sType == "city"){

      Address newAddress = Address();
      newAddress = newStudent.getAddress();

      if(newAddress.getCity() == sValue){
	foundValue = true;
	cout <<"\nFound a match for " << sValue << endl;
	cout << newStudent;
      }//end if
    }//end if
  }//end for

    if(!foundValue){
      cout << "\n*****************************String not found." << endl;
    }//end if

}//end method