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
| /**
| * chess.js
| * \
| * \__________________
| line | Anfangzeichen
| 0 | #
| 1 | <space>
| 2 | #
|
| */
|
| import {terminal} from "./dfhi.js";
|
| window.main = function(...argv) {
| let n = Number.parseInt(argv[0]);
| terminal.clear();
| printTopBottomLine(n);
| const black = '#',
| white = '*';
| for(let line = 0; line < n; ++line) {
| terminal.print("|");
| for(let row = 0; row < n; ++row) {
| const idx = (row+line) % 2;
| if(idx === 0) {
| terminal.print(black);
| } else {
| terminal.print(white);
| }
| }
| terminal.printl("|");
| }
| printTopBottomLine(n, '-');
| };
|
|
| function printTopBottomLine(n, symbol='_')
| {
| terminal.print('.');
| for(let i = 0; i < n; ++i) {
| terminal.print(symbol);
| }
| terminal.printl('.')
| }
|
|