commit 0e74a9eb90365c051ddf66ec00784559c79f8531
Author: ISman601 <33d9228@gmail.com>
Date: Thu May 14 09:17:54 2026 +0300
Start location LAB8
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/Lab8.iml b/.idea/Lab8.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/.idea/Lab8.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml
new file mode 100644
index 0000000..d6b475c
--- /dev/null
+++ b/.idea/material_theme_project_new.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..0b76fe5
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..b45f27b
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..fed06b3
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,24 @@
+cmake_minimum_required(VERSION 4.0)
+project(Lab8)
+
+set(CMAKE_CXX_STANDARD 20)
+
+add_executable(Lab8
+ src/main.cpp
+ src/Property/Property.cpp
+ src/Property/Property.h
+ src/Apartment/Apartment.cpp
+ src/Apartment/Apartment.h
+ src/Car/Car.cpp
+ src/Car/Car.h
+ src/CountryHouse/CountryHouse.cpp
+ src/CountryHouse/CountryHouse.h
+ src/Owner/Owner.cpp
+ src/Owner/Owner.h
+ src/TaxRates/TaxRates.h
+ src/Human/Human.cpp
+ src/Human/Human.h
+ src/City/City.cpp
+ src/City/City.h
+ src/PropertyFactory/PropertyFactory.cpp
+ src/PropertyFactory/PropertyFactory.h)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b30cca1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# hi
+**I am a** circle
\ No newline at end of file
diff --git a/diagrams/uml.puml b/diagrams/uml.puml
new file mode 100644
index 0000000..2ae29e4
--- /dev/null
+++ b/diagrams/uml.puml
@@ -0,0 +1,42 @@
+@startuml
+
+class Property {
+ # double price
+ # string address
+ + show()
+ + clone()
+}
+
+class Apartment {
+ - int rooms
+ + show()
+ + clone()
+}
+
+class Car {
+ - string brand
+ - int horsepower
+ + show()
+ + clone()
+}
+
+class CountryHouse {
+ - int floors
+ - double landArea
+ + show()
+ + clone()
+}
+
+class City {
+ - vector
+ + addProperty()
+ + showAll()
+}
+
+Property <|-- Apartment
+Property <|-- Car
+Property <|-- CountryHouse
+
+City o-- Property
+
+@enduml
\ No newline at end of file
diff --git a/json/input.json b/json/input.json
new file mode 100644
index 0000000..e69de29
diff --git a/json/output.json b/json/output.json
new file mode 100644
index 0000000..e69de29
diff --git a/src/Apartment/Apartment.cpp b/src/Apartment/Apartment.cpp
new file mode 100644
index 0000000..0fd8bfd
--- /dev/null
+++ b/src/Apartment/Apartment.cpp
@@ -0,0 +1,45 @@
+#include "Apartment.h"
+#include
+
+Apartment::Apartment() {
+ rooms = 0;
+
+ std::cout << "Apartment created\n";
+}
+
+Apartment::Apartment(double price,
+ std::string address,
+ int rooms)
+ : Property(price, address) {
+
+ this->rooms = rooms;
+
+ std::cout << "Apartment created\n";
+}
+
+void Apartment::addResident(Human* resident) {
+ residents.push_back(resident);
+}
+
+void Apartment::show() const {
+
+ std::cout
+ << "\nApartment\n"
+ << "Address: " << address << std::endl
+ << "Price: " << price << std::endl
+ << "Rooms: " << rooms << std::endl;
+
+ std::cout << "Residents:\n";
+
+ for (int i = 0; i < residents.size(); i++) {
+ residents[i]->showInfo();
+ }
+}
+
+Apartment::~Apartment() {
+ std::cout << "Apartment deleted\n";
+}
+
+std::unique_ptr Apartment::clone() const {
+ return std::make_unique(*this);
+}
diff --git a/src/Apartment/Apartment.h b/src/Apartment/Apartment.h
new file mode 100644
index 0000000..079dc43
--- /dev/null
+++ b/src/Apartment/Apartment.h
@@ -0,0 +1,26 @@
+#ifndef APARTMENT_H
+#define APARTMENT_H
+
+#include "../Property/Property.h"
+#include "../Human/Human.h"
+#include
+
+class Apartment : public Property {
+private:
+ int rooms;
+ std::vector residents;
+
+public:
+ Apartment();
+ Apartment(double price,
+ std::string address,
+ int rooms);
+
+ void addResident(Human* resident);
+
+ void show() const override;
+
+ ~Apartment();
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Car/Car.cpp b/src/Car/Car.cpp
new file mode 100644
index 0000000..b3f0429
--- /dev/null
+++ b/src/Car/Car.cpp
@@ -0,0 +1,38 @@
+#include "Car.h"
+#include
+
+Car::Car() {
+ brand = "Unknown";
+ horsepower = 0;
+
+ std::cout << "Car created\n";
+}
+
+Car::Car(double price,
+ std::string address,
+ std::string brand,
+ int horsepower)
+ : Property(price, address) {
+
+ this->brand = brand;
+ this->horsepower = horsepower;
+
+ std::cout << "Car created\n";
+}
+
+void Car::show() const {
+
+ std::cout
+ << "\nCar\n"
+ << "Brand: " << brand << std::endl
+ << "Horsepower: " << horsepower << std::endl
+ << "Price: " << price << std::endl;
+}
+
+Car::~Car() {
+ std::cout << "Car deleted\n";
+}
+
+std::unique_ptr Car::clone() const {
+ return std::make_unique(*this);
+}
\ No newline at end of file
diff --git a/src/Car/Car.h b/src/Car/Car.h
new file mode 100644
index 0000000..0ef468a
--- /dev/null
+++ b/src/Car/Car.h
@@ -0,0 +1,24 @@
+#ifndef CAR_H
+#define CAR_H
+
+#include "../Property/Property.h"
+
+class Car : public Property {
+private:
+ std::string brand;
+ int horsepower;
+
+public:
+ Car();
+
+ Car(double price,
+ std::string address,
+ std::string brand,
+ int horsepower);
+
+ void show() const override;
+
+ ~Car();
+};
+
+#endif
\ No newline at end of file
diff --git a/src/City/City.cpp b/src/City/City.cpp
new file mode 100644
index 0000000..f3d3dfd
--- /dev/null
+++ b/src/City/City.cpp
@@ -0,0 +1,49 @@
+#include "City.h"
+#include
+
+City::City() {
+ std::cout << "City created\n";
+}
+
+City::City(const City& other) {
+ std::cout << "City COPY\n";
+
+ for (const auto& p : other.properties) {
+ properties.push_back(p->clone());
+ }
+}
+
+City& City::operator=(const City& other) {
+
+ std::cout << "City ASSIGN\n";
+
+ if (this == &other)
+ return *this;
+
+ properties.clear();
+
+ for (const auto& p : other.properties) {
+ properties.push_back(p->clone());
+ }
+
+ return *this;
+}
+void City::addProperty(const Property& property) {
+ properties.push_back(property.clone());
+}
+
+void City::showAll() const {
+
+ std::cout << "\nCITY PROPERTY LIST\n";
+
+ for (const auto& p : properties) {
+ p->show();
+ }
+}
+
+City::~City() {
+ std::cout << "City destroyed\n";
+}
+
+
+
diff --git a/src/City/City.h b/src/City/City.h
new file mode 100644
index 0000000..748dbae
--- /dev/null
+++ b/src/City/City.h
@@ -0,0 +1,25 @@
+#ifndef CITY_H
+#define CITY_H
+
+#include
+#include
+#include "../Property/Property.h"
+
+class City {
+private:
+ std::vector> properties;
+
+public:
+ City();
+
+ void addProperty(const Property& property);
+
+ void showAll() const;
+
+ City(const City& other);
+ City& operator=(const City& other);
+
+ ~City();
+};
+
+#endif
\ No newline at end of file
diff --git a/src/CountryHouse/CountryHouse.cpp b/src/CountryHouse/CountryHouse.cpp
new file mode 100644
index 0000000..e851817
--- /dev/null
+++ b/src/CountryHouse/CountryHouse.cpp
@@ -0,0 +1,39 @@
+#include "CountryHouse.h"
+#include
+
+CountryHouse::CountryHouse() {
+ floors = 0;
+ landArea = 0;
+
+ std::cout << "CountryHouse created\n";
+}
+
+CountryHouse::CountryHouse(double price,
+ std::string address,
+ int floors,
+ double landArea)
+ : Property(price, address) {
+
+ this->floors = floors;
+ this->landArea = landArea;
+
+ std::cout << "CountryHouse created\n";
+}
+
+void CountryHouse::show() const {
+
+ std::cout
+ << "\nCountry House\n"
+ << "Address: " << address << std::endl
+ << "Floors: " << floors << std::endl
+ << "Land area: " << landArea << std::endl
+ << "Price: " << price << std::endl;
+}
+
+CountryHouse::~CountryHouse() {
+ std::cout << "CountryHouse deleted\n";
+}
+
+std::unique_ptr CountryHouse::clone() const {
+ return std::make_unique(*this);
+}
\ No newline at end of file
diff --git a/src/CountryHouse/CountryHouse.h b/src/CountryHouse/CountryHouse.h
new file mode 100644
index 0000000..fa6ac55
--- /dev/null
+++ b/src/CountryHouse/CountryHouse.h
@@ -0,0 +1,24 @@
+#ifndef COUNTRYHOUSE_H
+#define COUNTRYHOUSE_H
+
+#include "../Property/Property.h"
+
+class CountryHouse : public Property {
+private:
+ int floors;
+ double landArea;
+
+public:
+ CountryHouse();
+
+ CountryHouse(double price,
+ std::string address,
+ int floors,
+ double landArea);
+
+ void show() const override;
+
+ ~CountryHouse();
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Human/Human.cpp b/src/Human/Human.cpp
new file mode 100644
index 0000000..8897a51
--- /dev/null
+++ b/src/Human/Human.cpp
@@ -0,0 +1,45 @@
+#include "Human.h"
+#include
+
+Human::Human() {
+ name = "Unknown";
+ surname = "Unknown";
+ age = 0;
+
+ std::cout << "Human created\n";
+}
+
+Human::Human(std::string name, std::string surname, int age) {
+ this->name = name;
+ this->surname = surname;
+ this->age = age;
+
+ std::cout << "Human created: "
+ << name << " "
+ << surname << std::endl;
+}
+
+std::string Human::getName() const {
+ return name;
+}
+
+std::string Human::getSurname() const {
+ return surname;
+}
+
+int Human::getAge() const {
+ return age;
+}
+
+void Human::showInfo() const {
+ std::cout
+ << name << " "
+ << surname << ", age: "
+ << age << std::endl;
+}
+
+Human::~Human() {
+ std::cout << "Human deleted: "
+ << name << " "
+ << surname << std::endl;
+}
\ No newline at end of file
diff --git a/src/Human/Human.h b/src/Human/Human.h
new file mode 100644
index 0000000..0456bc4
--- /dev/null
+++ b/src/Human/Human.h
@@ -0,0 +1,25 @@
+#ifndef HUMAN_H
+#define HUMAN_H
+
+#include
+
+class Human {
+private:
+ std::string name;
+ std::string surname;
+ int age;
+
+public:
+ Human();
+ Human(std::string name, std::string surname, int age);
+
+ std::string getName() const;
+ std::string getSurname() const;
+ int getAge() const;
+
+ void showInfo() const;
+
+ ~Human();
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Owner/Owner.cpp b/src/Owner/Owner.cpp
new file mode 100644
index 0000000..99ab730
--- /dev/null
+++ b/src/Owner/Owner.cpp
@@ -0,0 +1,31 @@
+#include "Owner.h"
+#include
+
+Owner::Owner() : Human() {
+ std::cout << "Owner created\n";
+}
+
+Owner::Owner(std::string name,
+ std::string surname,
+ int age)
+ : Human(name, surname, age) {
+
+ std::cout << "Owner created\n";
+}
+
+void Owner::addProperty(Property* property) {
+ properties.push_back(property);
+}
+
+void Owner::showProperties() const {
+
+ std::cout << "\nOWNER PROPERTY LIST\n";
+
+ for (int i = 0; i < properties.size(); i++) {
+ properties[i]->show();
+ }
+}
+
+Owner::~Owner() {
+ std::cout << "Owner deleted\n";
+}
\ No newline at end of file
diff --git a/src/Owner/Owner.h b/src/Owner/Owner.h
new file mode 100644
index 0000000..804d098
--- /dev/null
+++ b/src/Owner/Owner.h
@@ -0,0 +1,26 @@
+#ifndef OWNER_H
+#define OWNER_H
+
+#include "../Human/Human.h"
+#include "../Property/Property.h"
+#include
+
+class Owner : public Human {
+private:
+ std::vector properties;
+
+public:
+ Owner();
+
+ Owner(std::string name,
+ std::string surname,
+ int age);
+
+ void addProperty(Property* property);
+
+ void showProperties() const;
+
+ ~Owner();
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Property/Property.cpp b/src/Property/Property.cpp
new file mode 100644
index 0000000..ada9c07
--- /dev/null
+++ b/src/Property/Property.cpp
@@ -0,0 +1,16 @@
+#include "Property.h"
+#include
+
+Property::Property() {
+ price = 0;
+ address = "Unknown";
+}
+
+Property::Property(double price, std::string address) {
+ this->price = price;
+ this->address = address;
+}
+
+Property::~Property() {
+ std::cout << "Property deleted\n";
+}
\ No newline at end of file
diff --git a/src/Property/Property.h b/src/Property/Property.h
new file mode 100644
index 0000000..ea9e525
--- /dev/null
+++ b/src/Property/Property.h
@@ -0,0 +1,23 @@
+#ifndef PROPERTY_H
+#define PROPERTY_H
+
+#include
+#include
+
+class Property {
+protected:
+ double price;
+ std::string address;
+
+public:
+ Property();
+ Property(double price, std::string address);
+
+ virtual void show() const = 0;
+
+ virtual std::unique_ptr clone() const = 0;
+
+ virtual ~Property();
+};
+
+#endif
\ No newline at end of file
diff --git a/src/PropertyFactory/PropertyFactory.cpp b/src/PropertyFactory/PropertyFactory.cpp
new file mode 100644
index 0000000..228ab74
--- /dev/null
+++ b/src/PropertyFactory/PropertyFactory.cpp
@@ -0,0 +1,21 @@
+#include "PropertyFactory.h"
+#include "../Apartment/Apartment.h"
+#include "../Car/Car.h"
+#include "../CountryHouse/CountryHouse.h"
+
+std::unique_ptr PropertyFactory::create(Type type) {
+
+ switch (type) {
+
+ case APARTMENT:
+ return std::make_unique(120000, "Moscow", 3);
+
+ case CAR:
+ return std::make_unique(30000, "Garage", "BMW", 250);
+
+ case COUNTRY_HOUSE:
+ return std::make_unique(500000, "Village", 2, 15.5);
+ }
+
+ return nullptr;
+}
\ No newline at end of file
diff --git a/src/PropertyFactory/PropertyFactory.h b/src/PropertyFactory/PropertyFactory.h
new file mode 100644
index 0000000..d99c408
--- /dev/null
+++ b/src/PropertyFactory/PropertyFactory.h
@@ -0,0 +1,18 @@
+#ifndef PROPERTYFACTORY_H
+#define PROPERTYFACTORY_H
+
+#include
+#include "../Property/Property.h"
+
+class PropertyFactory {
+public:
+ enum Type {
+ APARTMENT,
+ CAR,
+ COUNTRY_HOUSE
+ };
+
+ static std::unique_ptr create(Type type);
+};
+
+#endif
\ No newline at end of file
diff --git a/src/TaxRates/TaxRates.h b/src/TaxRates/TaxRates.h
new file mode 100644
index 0000000..2938198
--- /dev/null
+++ b/src/TaxRates/TaxRates.h
@@ -0,0 +1,43 @@
+#ifndef TAXRATES_H
+#define TAXRATES_H
+
+namespace TAX_RATES {
+
+ // ==========================
+ // НАЛОГИ ДЛЯ АВТОМОБИЛЕЙ
+ // ==========================
+
+ const double CAR_TAX = 0.0007;
+
+ const double CAR_TRUCK_TAX = 0.007;
+
+ const double CAR_LUXURY_TAX = 0.027;
+
+ // ==========================
+ // НАЛОГИ ДЛЯ КВАРТИР
+ // ==========================
+
+ const double APARTMENT_TAX = 0.001;
+
+ const double APARTMENT_LUXURY_TAX = 0.004;
+
+ // ==========================
+ // НАЛОГ ДЛЯ ДОМА
+ // ==========================
+
+ const double COUNTRY_HOUSE_TAX = 0.01;
+
+ // ==========================
+ // ГРАНИЦЫ
+ // ==========================
+
+ const double LOW_HORSEPOWER = 100;
+
+ const double HIGH_HORSEPOWER = 200;
+
+ const unsigned int LIMIT_DISTANCE_FROM_CITY = 30;
+
+ const int LIMIT_APARTMENT_SQUARE = 100;
+}
+
+#endif
\ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..3ddd0db
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,18 @@
+#include "City/City.h"
+#include "Apartment/Apartment.h"
+#include "Car/Car.h"
+#include "CountryHouse/CountryHouse.h"
+#include
+
+int main() {
+
+ City city;
+
+ city.addProperty(*PropertyFactory::create(PropertyFactory::CAR));
+ city.addProperty(*PropertyFactory::create(PropertyFactory::APARTMENT));
+ city.addProperty(*PropertyFactory::create(PropertyFactory::COUNTRY_HOUSE));
+
+ city.showAll();
+
+ return 0;
+}
\ No newline at end of file