Загрузка данных


#include <iostream>

using namespace std;

class Transport {
private:
	string brand;
	int price;
	double wheel;
public:
	Transport() {
		brand = "none";
		price = 0;
		wheel = 0;
	}
	Transport(string brand,int price,double wheel) {
		this->brand = brand;
		this->price = price;
		this->wheel = wheel;
	}
	Transport(const Transport& other) {
		brand = other.brand;
		price = other.price;
		wheel = other.wheel;
	}
	Transport(Transport&& other)noexcept {
		brand = other.brand;
		price = other.price;
		wheel = other.wheel;
		other.price = 0;
		other.wheel = 0;
	}
	Transport& operator=(const Transport& other) {
		if (this != &other) {
			brand = other.brand;
			price = other.price;
			wheel = other.wheel;
		}
		return *this;
	}
	Transport& operator=(Transport&& other)noexcept {
		if (this != &other) {
			brand = other.brand;
			price = other.price;
			wheel = other.wheel;
			other.price = 0;
			other.wheel = 0;
		}
		return *this;
	}

	string getBrand() {
		return brand;
	}
	int getPrice() {
		return price;
	}
	double getWheel() {
		return wheel;
	}
	
	void setBrand(string brand) {
		this->brand = brand;
	}
	void setPrice(int price) {
		this->price = price;
	}
	void setWheel(double wheel) {
		this->wheel = wheel;
	}

	bool operator==(const Transport& other) {
		if (brand == other.brand && price == other.price && wheel == other.wheel) {
			return true;
		}
	}
	friend ostream& operator<<(ostream& os, const Transport& h) {
		os << "Brand: " << h.brand << " price: " << h.price << " wheel size: " << h.wheel;
		return os;
	}
};

class Motocycle : public Transport{
private:
	double maxSpeed;
public:
	Motocycle() : Transport("none",0,0) {
		maxSpeed = 0;
	}
	Motocycle(string brand,int price,double wheel, double maxSpeed) : Transport(brand, price, wheel) {
		this->maxSpeed = maxSpeed;
	}
	Motocycle(const Motocycle& other) : Transport(other) {
		maxSpeed = other.maxSpeed;
	}
	Motocycle(Motocycle&& other)noexcept : Transport(other) {
		maxSpeed = other.maxSpeed;
		other.maxSpeed = 0;
	}
	bool operator<(const Motocycle& other) const {
		return maxSpeed < other.maxSpeed;
	}
};

class Car : public Transport{
private:
	string fuelType;
public:
	Car() : Transport("none", 0, 0) {
		fuelType = "none";
	}
	Car(string brand, int price, double wheel, string fuelType) : Transport(brand, price, wheel) {
		this->fuelType = fuelType;
	}
	Car(const Car& other) : Transport(other) {
		fuelType = other.fuelType;
	}
	Car(Car&& other)noexcept : Transport(other) {
		fuelType = other.fuelType;
	}
};

int main()
{
	Transport a1("Mazda", 140000, 24.0);
	Motocycle a2("Mazda", 140000, 24.0, 240);
	Car a3("Mazda", 140000, 24.0, "dizel");
	cout << a1 << endl;
	Car a4 = a3;
	Transport a6;
	bool R = a1 == a6;
	if (R == 0) {
		cout << "Ne ravno" << endl;
	}
	else {
		cout << "ravno" << endl;
	}

	Motocycle a8;
	if (a8 < a2) {
		cout << "a8 faster";
	}
}