-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmentorMateTask.js
45 lines (36 loc) · 1021 Bytes
/
mentorMateTask.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
43
44
45
class LineBuilder {
constructor() {
this.line = "";
}
withDashes(n) {
this.line = this.line.concat('-'.repeat(n));
return this;
}
withStars(n) {
this.line = this.line.concat('*'.repeat(n));
return this;
}
repeat(n) {
this.line = this.line.repeat(n);
return this;
}
build() {
return this.line;
}
}
function drawMentorMate(n) {
for (let i = 0; i < n / 2; i++) {
let line = new LineBuilder()
.withDashes(n - i).withStars(n + 2 * i).withDashes(n - 2 * i).withStars(n + 2 * i).withDashes(n - i)
.repeat(2).build();
console.log(line)
}
for (let i = 0; i < n / 2; i++) {
let line = new LineBuilder()
.withDashes((n / 2) - i).withStars(n).withDashes(1 + 2 * i).withStars(n * 2 - 2 * i - 1)
.withDashes(1 + 2 * i).withStars(n).withDashes((n / 2) - i)
.repeat(2).build();
console.log(line);
}
}
drawMentorMate(5);