Self-complete

This commit is contained in:
2026-05-22 14:49:02 +03:00
parent 0e74a9eb90
commit a5d6b3af21
47 changed files with 7003 additions and 570 deletions
+90
View File
@@ -0,0 +1,90 @@
#include "Car.h"
#include "TaxRates.h"
Car::Car(double worth,
double horsepower)
: Property(worth)
{
this->horsepower = horsepower;
}
double Car::calculateTax()
{
if (horsepower <
TAX_RATES::LOW_HORSEPOWER)
{
return worth *
TAX_RATES::CAR_TAX;
}
if (horsepower <=
TAX_RATES::HIGH_HORSEPOWER)
{
return worth *
TAX_RATES::CAR_TRUCK_TAX;
}
return worth *
TAX_RATES::CAR_LUXURY_TAX;
}
void Car::fromJson(json j)
{
worth = j["worth"];
horsepower =
j["horsepower"];
}
json Car::toJson()
{
json j;
j["worth"] = worth;
j["horsepower"] =
horsepower;
j["tax"] =
calculateTax();
return j;
}
void Car::fromXml(
XMLElement* element)
{
element->QueryDoubleAttribute(
"worth",
&worth
);
element->QueryDoubleAttribute(
"horsepower",
&horsepower
);
}
XMLElement* Car::toXml(
XMLDocument& doc)
{
XMLElement* element =
doc.NewElement("Car");
element->SetAttribute(
"worth",
worth
);
element->SetAttribute(
"horsepower",
horsepower
);
element->SetAttribute(
"tax",
calculateTax()
);
return element;
}