#include <iostream>
#include <string>
using namespace std;
class land{
public:
land();
land(char* n, char* k, int p, int s, string h, int b);
land(const land& a);
~land();
void editName(char*n);
void editKind(char*k);
void editPopulation(int p);
void editSpace(int s);
void editHead(string h);
void editBudget(int b);
friend ostream& operator <<(ostream& o, land& a);
friend istream& operator >>(istream& i, land& a);
land operator + ( int up);
friend bool operator > (const land a, const land b);
friend bool operator < (const land a, const land b);
friend bool operator == (const land a, const land b);
land operator % (int ub);
private:
char* name;
char* kind;
int population;
int space;
string head;
int budget;
};
land::land(){
name = "unknown";
kind = "unknown";
population = 0;
space = 0;
head = "Anonymous";
budget = 0;
}
land::land(char* n, char* k, int p, int s, string h, int b){
name = n;
kind = k;
population = p;
space = s;
head = h;
budget = b;
}
land::land(const land& a){
this->name = a.name;
this->kind = a.kind;
this->population = a.population;
this->space = a.space;
this->head = a.head;
this->budget = a.budget;
}
void land::editName(char* n){
this->name = n;
}
void land::editKind(char* k){
this->kind = k;
}
void land::editPopulation(int p){
this->population = p;
}
void land::editSpace(int s){
this->space = s;
}
void land::editHead(string h){
this ->head = h;
}
void land::editBudget(int b){
this->budget = b;
}
istream& operator >> (istream& i, land& a){
i >> a.name >> a.kind >> a.population >> a.space >> a.head >> a.budget;
return i;
}
ostream& operator << (ostream& o, land& a){
o << a.name << " " << a.kind << " " << a.population << " " << a.space << " " << a.head << " " << a.budget << endl;
return o;
}
bool operator > (const land a, const land b){
if(a.population == b.population)
return a.space > b.space;
else return a.population > b.population;
}
bool operator < (const land a, const land b){
if(a.population == b.population)
return a.space < b.space;
else return a.population < b.population;
}
bool operator == (const land a, const land b){
if(a.population != b.population)
return 0;
else return a.space == b.space;
}
/*land operator + (int up){
this->population += up;
return this;
}*/
land::~land(){
}
int main()
{
land test, test2;
cin >> test; // >> operator doesn't work
//test of output operators and methods of edition of containment (and comparison operators too)
cout << test;
test.editBudget(650);
test.editHead("Head");
test.editKind("City");
test.editName("Name");
test.editPopulation(789);
test.editSpace(888);
cout << test << endl << (test<test2) << ' ' << (test>test2) << ' ' << (test==test2);
return 0;
}