forked from turingschool-examples/javascript-foundations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
golfer.js
42 lines (41 loc) · 1.08 KB
/
golfer.js
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
class Golfer {
constructor(personInfo) {
this.name = personInfo.name;
this.handicap = personInfo.handicap
this.frustration = 0;
this.confidence = 0;
}
calculateAvg(par) {
var avgPar = par + this.handicap;
return `I usually shoot a ${avgPar} on average.`
}
playRound(courseInfo) {
if (courseInfo.difficulty === 'hard') {
this.frustration = 500;
}
if (courseInfo.difficulty === 'moderate') {
this.frustration = 100;
}
}
hitTheRange() {
this.confidence += 10;
}
whatYaShoot(num) {
if (num > 0) {
this.frustration += 20;
return 'Doh!';
}
if (num === 0) {
this.frustration -= 10;
return 'Booyah!';
}
if (num < 0) {
this.frustration = 0;
return 'I AM THE GREATEST GOLFER ALIVE!';
}
}
marvel(courseInfo) {
return `I love the ${courseInfo.features[0]} and ${courseInfo.features[1]} on this course!`;
}
}
module.exports = Golfer;