-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVan.cpp
36 lines (24 loc) · 1019 Bytes
/
Van.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
#include "Van.h"
Van::Van(int maxVol, int maxWeight, int cost) : maxVol(maxVol), maxWeight(maxWeight), cost(cost) {
profit -= cost;
}
int Van::getMaxVol() const {return maxVol;}
void Van::setMaxVol(int maxVol) {Van::maxVol = maxVol;}
int Van::getMaxWeight() const {return maxWeight;}
void Van::setMaxWeight(int maxWeight) {Van::maxWeight = maxWeight;}
int Van::getCost() const {return cost;}
int Van::getProfit() const {return profit;}
bool Van::checkVol(int vol) const { return maxVol > vol;}
bool Van::checkWeight(int weight) const { return maxWeight > weight;}
void Van::occupySpace(Parcel& parcel) {
maxVol -= parcel.getVol();
maxWeight -= parcel.getWeight();
profit += parcel.getCost();
}
bool Van::operator<(const Van &van) const {
return maxVol * maxWeight / cost > van.maxVol * van.maxWeight / van.cost;
}
ostream& operator<<(ostream& out, Van& v1) {
out << v1.getMaxVol() << " " << v1.getMaxWeight() << " " << v1.getCost() << " " << v1.getProfit() << endl;
return out;
}