Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <vector>
- using namespace std;
- enum Material {
- BRICK,
- CONCRETE,
- WOOD,
- STONE,
- GLASS
- };
- class Registered {
- public:
- virtual string getLocation() {
- return "";
- }
- };
- /**
- * ! EXERCISE #1 -- COMPLETE ABSTRACT BUILDING CLASS. REFACTOR SUBCLASSES.
- *
- * ! EXERCISE #3 -- BUILDING SUBCLASS OF REGISTERED.
- *
- */
- class Building : public Registered {
- protected:
- string city;
- int buildingNumber;
- int age; // age of building in years
- int area; // area in sq. ft.
- Material material;
- public:
- string neighborhood;
- vector<string> residents;
- string storeName;
- virtual string getCity() { return city; }
- virtual int getBuildingNumber() { return buildingNumber; }
- virtual int getAge() { return age; }
- virtual int getArea() { return area; }
- virtual Material getMaterial() { return material; }
- void setCity(string city) { this->city = city; }
- void setBuildingNumber(int buildingNumber) { this->buildingNumber = buildingNumber; }
- void setAge(int age) { this->age = age; }
- void setArea(int area) { this->area = area; }
- void setMaterial(Material material) { this->material = material; }
- Building(string city, int buildingNumber, int age, int area, Material material) : city(city), buildingNumber(buildingNumber), age(age), area(area), material(material) {};
- static int findNewestBuilding(vector<Building *> buildings) {
- return -11;
- }
- static bool existMaterialFromCity(vector<Building *> &buildings, string city, Material material) {
- return true || false;
- }
- static unsigned int countYoungerBuildings(vector<Building *> buildings) {
- return 999;
- }
- }; // End of abstract Building class
- class House : public Building {
- private:
- string neighborhood;
- vector<string> residents;
- public:
- House() : House("", "", 0, 0, 0, Material::BRICK){};
- House(string city, string neighborhood, int buildingNumber, int age, int area, Material material ) : Building(city, buildingNumber, age, area, material){
- this->neighborhood = neighborhood;
- }
- string getNeighborhood() { return neighborhood; }
- vector<string> getResidents() { return residents; }
- void setNeighborhood(string n) { neighborhood = n; }
- void setResidents(vector<string> r) { residents = r; }
- string getLocation() {
- return (neighborhood + ", " + to_string(buildingNumber) + ", " + to_string(age));
- }
- }; // End of House class
- class Store : public Building {
- private:
- string storeName;
- public:
- Store() : Store("", "", 0, 0, 0, Material::BRICK){};
- Store(string storeName, string city, int buildingNumber, int age, int area, Material material) : Building(city, buildingNumber, age, area, material){
- this->storeName = storeName;
- }
- string getStoreName() { return storeName; }
- void setStoreName(string storeName) { this->storeName = storeName; }
- string getLocation() {
- return (city + ", " + to_string(buildingNumber) + ", " + to_string(area));
- }
- }; // End of Store class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement