-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPriceState.cpp
More file actions
32 lines (24 loc) · 842 Bytes
/
PriceState.cpp
File metadata and controls
32 lines (24 loc) · 842 Bytes
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
//
// PriceState.cpp
// Labo4
//
// Created by Nohan Budry on 16.06.19.
//
#include "PriceState.h"
PriceState::PriceState(double basePrice, int nbDayBasePrice, double additionalPrice, int renterPoint)
: BASE_PRICE(basePrice), NB_DAY_BASE_PRICE(nbDayBasePrice), ADDITIONAL_PRICE(additionalPrice), RENTER_POINT(renterPoint) {}
double PriceState::calculatePrice(int nbDayRented) const {
double price = BASE_PRICE;
if (nbDayRented > NB_DAY_BASE_PRICE)
price += (nbDayRented - NB_DAY_BASE_PRICE) * ADDITIONAL_PRICE;
return price;
}
int PriceState::renterPoint() const {
return RENTER_POINT;
}
RegularPriceState::RegularPriceState()
: PriceState(2, 2, 1.5, 0) {}
ChildrenPriceState::ChildrenPriceState()
: PriceState(1.5, 3, 1.5, 0) {}
NewReleasePriceState::NewReleasePriceState()
: PriceState(3, 1, 3, 1) {}