forked from furkankirac/cs321-2019-20-fall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweek3-lab.cpp
44 lines (31 loc) · 1.03 KB
/
week3-lab.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
struct House
{
double area;
double price;
double price_per_msqr;
bool operator<(const House house) const { return price_per_msqr<house.price_per_msqr; }
bool operator>(const House house) const { return price_per_msqr>house.price_per_msqr; }
bool operator==(const House house) { return price_per_msqr == house.price_per_msqr; }
House(const double area, const double price) : area(area), price(price)
{
price_per_msqr = price/area;
}
void print() const{
std::cout<< "price: " << price << "\narea "<< area <<"\nprice per msqr: " << price_per_msqr << std::endl;
}
};
int main(int argc, char* argv[])
{
House h1{10,100};
House h2{10,10};
h1.print();
h2.print();
if (h1==h2)
std::cout << "Same houses!" << std::endl;
else if(h1>h2)
std::cout << "h1 is more expensive than h2" << std::endl;
else
std::cout << "h2 is more expensive than h1" << std::endl;
return 0;
}