// Apartment Implementation File // #include #include #include #include #include "Apartment.h" using namespace std; Apartment::Apartment() : Person() { aptno = ""; avail = ""; } Apartment::Apartment(string inAptno, string inAvail, string inName) : Person(inName) { aptno = inAptno; avail = inAvail; Person::setName(inName); } string Apartment::getAptrNumber() { return aptno; } string Apartment::getName() { return Person::getName(); } string Apartment::getAptrTen(vector apartmentVec, string inAptno) { auto it = find_if(apartmentVec.begin(), apartmentVec.end(), [&inAptno](Apartment& obj) { return obj.getAptrNumber() == inAptno; }); // We use the function find_if from the library to search our vector for the string entered by the user (inAptno). Apartment tempU = *it; // Once we have a match, we create a temporary tenant which holds the information retrieved from it (using a pointer for it, holding its values). return tempU.getName(); // in our return, we call the function getName() which returns the name of the member by scoping our base class (Person). } bool Apartment::roomNumCheck(vector apartmentVec, string inAptno) { auto it = find_if(apartmentVec.begin(), apartmentVec.end(), [&inAptno](Apartment& obj) { return obj.getAptrNumber() == inAptno; }); if (it != apartmentVec.end()) { return true; } else { return false; } } void Apartment::print() { cout << "Apartment Room: " << aptno << ", " << avail << ": " << Person::getName() << endl; }