-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParcel.cpp
25 lines (17 loc) · 836 Bytes
/
Parcel.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
#include "Parcel.h"
Parcel::Parcel(int vol, int weight, int cost, int duration) : vol(vol), weight(weight), cost(cost), duration(duration) {}
int Parcel::getVol() const {return vol;}
int Parcel::getWeight() const {return weight;}
int Parcel::getCost() const {return cost;}
int Parcel::getDuration() const {return duration;}
bool Parcel::operator<(const Parcel &parcel) const {
if (cost == parcel.cost) return vol * weight < parcel.vol * parcel.weight;
return cost > parcel.cost;
}
bool Parcel::operator==(const Parcel &parcel) const {
return vol == parcel.vol && weight == parcel.weight && cost == parcel.cost && duration == parcel.duration;
}
ostream& operator<<(ostream& out, Parcel& p1) {
out << p1.getVol() << " " << p1.getWeight() << " " << p1.getCost() << " " << p1.getDuration() << endl;
return out;
}