-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebsite.cpp
More file actions
69 lines (57 loc) · 1.29 KB
/
Website.cpp
File metadata and controls
69 lines (57 loc) · 1.29 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
65
66
67
68
69
#include "Website.h"
Website::Website(string name, int imp, int cl) {
//index is the index of the website in the vector of websites in the source.cpp file
//the default value of impressions is 1
//as putting it with 0 might cause run time error when we Calculate CTR
this->name = name;
index = count++;
if (imp > 0)
impressions = imp;//as we will divide by it in getCTR
else
impressions = 1;
if (cl >= 0)
clicks = cl;
else
clicks = 0;
PR = 0;//Inital value
}
void Website::incrementImp() {
impressions++;
}
void Website::incrementClick() {
clicks++;
}
double Website::getCTR() {
return (double)clicks / impressions;
}
int Website::getImp() {
return impressions;
}
int Website::getClick() {
return clicks;
}
int Website::getIndex() {
return index;
}
double Website::getPR() {
return PR;
}
string Website::getName() {
return name;
}
double Website::getScore() {
double frac = (0.1 * impressions) / (1.0 + 0.1 * impressions);
return 0.4 * PR + ((1 - frac) * PR + frac * getCTR()) * 0.6;
}
void Website::setImpressions(int impressions) {
if(impressions>0)//as we will divide by it in getCTR
this->impressions = impressions;
}
void Website::setClicks(int clicks) {
if(clicks>=0)
this->clicks = clicks;
}
void Website::setPR(double PR){
this->PR = PR;
}
int Website::count = 0;