Advertisement
AbsolutelyS

Untitled

Apr 18th, 2024
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.17 KB | None | 0 0
  1. #include <string>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. enum Material {
  7.     BRICK,
  8.     CONCRETE,
  9.     WOOD,
  10.     STONE,
  11.     GLASS
  12. };
  13.  
  14. class Registered {
  15.     public:
  16.     virtual string getLocation() {
  17.         return "";
  18.         }
  19. };
  20.  
  21. /**
  22.  * ! EXERCISE #1 -- COMPLETE ABSTRACT BUILDING CLASS. REFACTOR SUBCLASSES.
  23.  *
  24.  * ! EXERCISE #3 -- BUILDING SUBCLASS OF REGISTERED.
  25.  *
  26.  */
  27.  
  28. class Building : public Registered {
  29.   protected:
  30.     string city;
  31.     int buildingNumber;
  32.     int age;  // age of building in years
  33.     int area; // area in sq. ft.
  34.     Material material;
  35.  
  36.   public:
  37.     string neighborhood;
  38.     vector<string> residents;
  39.     string storeName;
  40.  
  41.     virtual string getCity() { return city; }
  42.     virtual int getBuildingNumber() { return buildingNumber; }
  43.     virtual int getAge() { return age; }
  44.     virtual int getArea() { return area; }
  45.     virtual Material getMaterial() { return material; }
  46.    
  47.  
  48.     void setCity(string city) { this->city = city; }
  49.     void setBuildingNumber(int buildingNumber) { this->buildingNumber = buildingNumber; }
  50.     void setAge(int age) { this->age = age; }
  51.     void setArea(int area) { this->area = area; }
  52.     void setMaterial(Material material) { this->material = material; }
  53.    
  54.     Building(string city, int buildingNumber, int age, int area, Material material) : city(city), buildingNumber(buildingNumber), age(age), area(area), material(material) {};
  55.  
  56.     static int findNewestBuilding(vector<Building *> buildings) {
  57.         return -11;
  58.     }
  59.  
  60.  
  61.     static bool existMaterialFromCity(vector<Building *> &buildings, string city, Material material) {
  62.         return true || false;
  63.     }
  64.  
  65.  
  66.     static unsigned int countYoungerBuildings(vector<Building *> buildings) {
  67.         return 999;
  68.     }
  69.  
  70. }; // End of abstract Building class
  71.  
  72. class House : public Building {
  73.   private:
  74.     string neighborhood;
  75.     vector<string> residents;
  76.  
  77.   public:
  78.     House() : House("", "", 0, 0, 0, Material::BRICK){};
  79.  
  80.     House(string city, string neighborhood, int buildingNumber, int age, int area, Material material ) : Building(city, buildingNumber, age, area, material){
  81.         this->neighborhood = neighborhood;
  82.     }
  83.  
  84.     string getNeighborhood() { return neighborhood; }
  85.     vector<string> getResidents() { return residents; }
  86.  
  87.     void setNeighborhood(string n) { neighborhood = n; }
  88.     void setResidents(vector<string> r) { residents = r; }
  89.  
  90.     string getLocation() {
  91.         return (neighborhood + ", " + to_string(buildingNumber) + ", " + to_string(age));
  92.         }
  93.  
  94. }; // End of House class
  95.  
  96. class Store : public Building {
  97.   private:
  98.     string storeName;
  99.  
  100.   public:
  101.     Store() : Store("", "", 0, 0, 0, Material::BRICK){};
  102.     Store(string storeName, string city, int buildingNumber, int age, int area, Material material)  : Building(city, buildingNumber, age, area, material){
  103.         this->storeName = storeName;
  104.     }
  105.     string getStoreName() { return storeName; }
  106.  
  107.     void setStoreName(string storeName) { this->storeName = storeName; }
  108.  
  109.     string getLocation() {
  110.     return (city + ", " + to_string(buildingNumber) + ", " + to_string(area));
  111.     }
  112.  
  113. }; // End of Store class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement