Skip to content

Commit a910bdf

Browse files
committed
Class 11 studio
1 parent 3d2a2f2 commit a910bdf

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

classes/studio/ClassStudio.js

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,58 @@
11
//Declare a class called CrewCandidate with a constructor that takes three parameters—name, mass, and scores. Note that scores will be an array of test results.
2+
class CrewCandidate {
3+
constructor(name, mass, scores) {
4+
this.name = name;
5+
this.mass = mass;
6+
this.scores = scores;
7+
}
8+
addScore(score) {
9+
this.scores.push(score);
10+
return this.scores
11+
}
12+
average() {
13+
let avg = 0
14+
for (let i = 0; i < this.scores.length; i++) {
15+
avg = (avg + this.scores[i])
16+
}
17+
avg = (avg / this.scores.length)
18+
avg = Math.round (avg * 10)/10
219

20+
return avg
21+
}
22+
status() {
23+
let candidateStatus = "";
24+
let candidateScore = this.average()
25+
if (candidateScore >= 90) {
26+
candidateStatus = "Accepted"
27+
} else if (candidateScore <= 89 && candidateScore >= 80) {
28+
candidateStatus = "Reserve"
29+
} else if (candidateScore <= 79 && candidateScore >= 70) {
30+
candidateStatus = "Probationary"
31+
} else if (candidateScore < 70) {
32+
candidateStatus = "Rejected"
33+
}
34+
return candidateStatus
35+
}
36+
}
337

38+
let bubbaBear = new CrewCandidate('Bubba Bear', 135, [88, 85, 90]);
39+
let merryMaltese = new CrewCandidate('Merry Maltese', 1.5, [93, 88, 97]);
40+
let gladGator = new CrewCandidate('Glad Gator', 225, [75, 78, 62]);
441

5-
//Add methods for adding scores, averaging scores and determining candidate status as described in the studio activity.
642

43+
// console.log(bubbaBear);
44+
// console.log(merryMaltese);
45+
// console.log(gladGator);
46+
bubbaBear.addScore(83)
47+
48+
// console.log(bubbaBear.scores)
49+
50+
// console.log(merryMaltese.average());
51+
52+
//Add methods for adding scores, averaging scores and determining candidate status as described in the studio activity.
53+
console.log(`Bubba Bear earned an average test score of ${bubbaBear.average()}% and has a status of ${bubbaBear.status()}`);
54+
console.log(`Merry Maltese earned an average test score of ${merryMaltese.average()}% and has a status of ${merryMaltese.status()}`);
55+
console.log(`Glad Gator earned an average test score of ${gladGator.average()}& and has a status of ${gladGator.status()}`);
756

857

9-
//Part 4 - Use the methods to boost Glad Gator’s status to Reserve or higher. How many tests will it take to reach Reserve status? How many to reach Accepted? Remember, scores cannot exceed 100%.
58+
//Part 4 - Use the methods to boost Glad Gator’s status to Reserve or higher. How many tests will it take to reach Reserve status? How many to reach Accepted? Remember, scores cannot exceed 100%.

0 commit comments

Comments
 (0)