This repository was archived by the owner on Nov 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBreedingConstraints.cpp
More file actions
64 lines (54 loc) · 1.36 KB
/
BreedingConstraints.cpp
File metadata and controls
64 lines (54 loc) · 1.36 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "BreedingConstraints.hpp"
using namespace breeding;
dog::dog(
const char * & name, int & age, float & weight,
breed_entry entry)
{
this->name = name;
this->age = age;
this->weight = weight;
this->entry = entry;
}
dog::~dog()
{
delete &this->entry;
}
auto dog::get_premium(void) -> float
{
auto base = this->get_base_premium();
if (this->entry.subject_to_senior_discount && this->age > constants::SENIOR_AGE)
base -= base * constants::ADDITIONAL_SENIOR_DISCOUNT;
if (this->weight > constants::WEIGHT_CHARGE)
base += base * constants::ADDITIONAL_WEIGHT_CHARGE;
return base;
}
auto dog::get_base_premium(void) -> float
{
return this->weight < entry.risk_weight
? entry.below_risk_weight
: entry.high_risk_weight;
}
other_breed::other_breed(
const char * & name, int & age, float & weight,
breed_entry entry)
: dog(name, age, weight, entry) { }
other_breed::~other_breed()
{ }
auto other_breed::get_base_premium(void) -> float
{
return entry.below_risk_weight;
}
auto breeding::factory::get_dog(
const char *& name, int & age, float & weight,
breed_entry entry) -> dog *
{
auto instance = new dog(name, age, weight, entry);
return instance;
}
auto breeding::factory::get_other_dog(
const char *& name, int & age, float & weight,
breed_entry entry) -> other_breed *
{
auto instance = new other_breed(name, age, weight, entry);
return instance;
}