Determine sales price and assets (not precise)

Investors with large real-estate portfolios may find that it is not always easy to preserve a good overview of their assets. They can have too many of them, where each one comes with its own characteristics that must be known in advance of a meeting with potential clients. While discussing the details, interested buyers may aks about the sales price, which would be a variable comprised of many other factors that must be known in advance.

One of the advantages of the C++ language lies in its expressiveness and the ability to accurately represent complex objects and their relationships. In the code below we can see that the more accurate the representation of an object, the more precisely we can determine characteristics which depend on some form of a composite. Full precision would be impossible to achieve without the close collaboration with the person who knows the details best. For this reason, we will treat the following example as a template.

#include <iostream> #include <vector> using namespace std; struct Room { string type; double quadrature; }; struct ApartmentObject { string name; double estimated_price; }; class Apartment { double total_quadrature; double average_price_per_sqm; double desired_profit_percentage; double property_tax_percentage; double empty_price; double furnished_price; vector<Room> rooms; vector<ApartmentObject> apobjs; public: Apartment(double ppsm, double pp, double pt) { average_price_per_sqm = ppsm; desired_profit_percentage = pp; property_tax_percentage = pt; } double estimate_sale_price() { return furnished_price * (1 + desired_profit_percentage/100); } double estimate_keep_cost() { return furnished_price * (property_tax_percentage/100); } void add_rooms(vector<Room> r) { rooms = r; get_total_quadrature(); } void add_objects(vector<ApartmentObject> apo) { apobjs = apo; get_furnished_price(); } void get_total_quadrature() { total_quadrature = 0.0; for(auto r : rooms) { total_quadrature += r.quadrature; } empty_price = total_quadrature * average_price_per_sqm; } void get_furnished_price() { double p = 0.0; for(auto apobj : apobjs) { p += apobj.estimated_price; } furnished_price = empty_price + p; } }; class Portfolio { vector<Apartment> apps; public: double estimate_total_assets() { double assets = 0.0; for(auto app:apps) { assets += app.estimate_sale_price(); } return assets; } double estimate_total_keep_cost() { double keep_cost = 0.0; for(auto app:apps) { keep_cost += app.estimate_keep_cost(); } return keep_cost; } void add_properties(vector<Apartment> ap) { apps = ap; } }; int main() { Portfolio portfolio; Apartment // avg. price/m2, profit percentage, property tax ap1(630.0, 12.5, 7.0), ap2(580.0, 18.0, 8.5), ap3(920, 10.0, 7.5); // Apartment 1 Room // type, quadrature r1a{"corridor", 8.0}, r2a{"living_room", 67.3}, r3a{"bedroom", 37.2}, r4a{"bathroom", 11.0}, r5a{"kitchen", 16.0}; ApartmentObject // name, estimated price obj1a{"Wasching machine", 380.0}, obj2a{"Dishwasher", 420.0}, obj3a{"Stove", 630.0}, obj4a{"Bed", 160.0}, obj5a{"Bed", 140.0}, obj6a{"Door", 90.0}, obj7a{"Door", 70.0}, obj8a{"Door", 65.0}, obj9a{"Sofa", 320.0}, obj10a{"Sofa", 230.0}, obj11a{"TV", 630.0}, obj12a{"Carpet", 80.0}, obj13a{"Aquarium", 220.0}, obj14a{"Lights", 90.0}; ap1.add_rooms(vector<Room> {r1a, r2a, r3a, r4a, r5a}); ap1.add_objects(vector<ApartmentObject> {obj1a, obj2a, obj3a, obj4a, obj5a, obj6a, obj7a, obj8a, obj9a, obj10a, obj11a, obj12a, obj13a, obj14a}); // Apartment 2 Room // type, quadrature r1b{"corridor", 12.5}, r2b{"living_room", 35.7}, r3b{"living_room", 42.4}, r4b{"bedroom", 27.0}, r5b{"bedroom", 27.0}, r6b{"bathroom", 13.0}, r7b{"kitchen", 18.0}, r8b{"storeroom", 5.0}; ApartmentObject // name, estimated price obj1b{"Complete kitchen furnishing", 1200.0}, obj2b{"Complete living room furnishing", 3200.0}, obj3b{"Extra large & durable windows", 280.0}, obj4b{"Modern massage-supporting shower", 80}, obj5b{"Bath", 140}, obj6b{"Gas water heater", 80}, obj7b{"Door", 60.0}, obj8b{"Door", 50.0}, obj9b{"Door", 55.0}, obj10b{"Sofa", 90.0}, obj11b{"TV", 310.0}, obj12b{"Radio", 25.0}, obj13b{"Parquet", 60.0}, obj14b{"Wall paint allowing marker drawing", 130.0}; ap2.add_rooms(vector<Room> {r1b, r2b, r3b, r4b, r5b, r6b, r7b, r8b}); ap2.add_objects(vector<ApartmentObject> {obj1b, obj2b, obj3b, obj4b, obj5b, obj6b, obj7b, obj8b, obj9b, obj10b, obj11b, obj12b, obj13b, obj14b}); // Apartment 3 Room // type, quadrature r1c{"corridor", 7.0}, r2c{"living_room", 34.2}, r3c{"bedroom", 26.0}, r4c{"bathroom", 11.0}, r5c{"kitchen", 14.0}; ApartmentObject // name, estimated price obj1c{"Wasching machine", 380.0}, obj2c{"Boiler", 380.0}, obj3c{"Dishwasher", 420.0}, obj4c{"Stove", 630.0}, obj5c{"Bed", 160.0}, obj6c{"Bed", 140.0}, obj7c{"Door", 50.0}, obj8c{"Door", 50.0}, obj9c{"Sofa", 320.0}, obj10c{"Sofa", 230.0}; ap2.add_rooms(vector<Room> {r1c, r2c, r3c, r4c, r5c}); ap2.add_objects(vector<ApartmentObject> {obj1c, obj2c, obj3c, obj4c, obj5c, obj6c, obj7c, obj8c, obj9c, obj10c}); // Add all apartments to the portfolio portfolio.add_properties(vector<Apartment> {ap1, ap2, ap3}); double total_assets = portfolio.estimate_total_assets(); double keep_costs = portfolio.estimate_total_keep_cost(); cout << "Total keep cost: $" << keep_costs << endl << "Total assets: $" << total_assets << endl; return 0; } /* Total keep cost: $11178.8 Total assets: $169195 */

What we see here is a small portfolio of three apartments, each one specified with its rooms, their quadrature and additional furniture. All of these are taken into account when calculating the final price so that a desired level of profitability can be achieved. There is a keep cost for each unsold property, determined as a percentage of its overall price. At the end we compute the total asset price as a sum of the individual asset values.

We can see that the code is not optimal since we have to do some manual work when adding new rooms and objects. Compared to other languages, we cannot redeclare already initialized variables, which is why they need to be unique. But specifying everything this way gives us a lot of flexibility, so that we can describe even minor details about each apartment. This may not be necessary what a portfolio manager needs, but the details can be eventually adjusted after learning the truly important.