Skip to content

Commit fd61c64

Browse files
authored
Merge pull request #181 from otmon76/1.9.1
Class basic syntax
2 parents 37092f5 + a16531c commit fd61c64

File tree

5 files changed

+240
-240
lines changed

5 files changed

+240
-240
lines changed
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
class Clock {
2-
constructor({ template }) {
3-
this.template = template;
1+
class Hodiny {
2+
constructor({ šablona }) {
3+
this.šablona = šablona;
44
}
55

6-
render() {
7-
let date = new Date();
6+
vypiš() {
7+
let datum = new Date();
88

9-
let hours = date.getHours();
10-
if (hours < 10) hours = '0' + hours;
9+
let hodiny = datum.getHours();
10+
if (hodiny < 10) hodiny = '0' + hodiny;
1111

12-
let mins = date.getMinutes();
13-
if (mins < 10) mins = '0' + mins;
12+
let minuty = datum.getMinutes();
13+
if (minuty < 10) minuty = '0' + minuty;
1414

15-
let secs = date.getSeconds();
16-
if (secs < 10) secs = '0' + secs;
15+
let sekundy = datum.getSeconds();
16+
if (sekundy < 10) sekundy = '0' + sekundy;
1717

18-
let output = this.template
19-
.replace('h', hours)
20-
.replace('m', mins)
21-
.replace('s', secs);
18+
let výstup = this.šablona
19+
.replace('h', hodiny)
20+
.replace('m', minuty)
21+
.replace('s', sekundy);
2222

23-
console.log(output);
23+
console.log(výstup);
2424
}
2525

2626
stop() {
27-
clearInterval(this.timer);
27+
clearInterval(this.časovač);
2828
}
2929

3030
start() {
31-
this.render();
32-
this.timer = setInterval(() => this.render(), 1000);
31+
this.vypiš();
32+
this.časovač = setInterval(() => this.vypiš(), 1000);
3333
}
3434
}
3535

3636

37-
let clock = new Clock({template: 'h:m:s'});
38-
clock.start();
37+
let hodiny = new Hodiny({šablona: 'h:m:s'});
38+
hodiny.start();
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
function Clock({ template }) {
1+
function Hodiny({ šablona }) {
22

3-
let timer;
3+
let časovač;
44

5-
function render() {
6-
let date = new Date();
5+
function vypiš() {
6+
let datum = new Date();
77

8-
let hours = date.getHours();
9-
if (hours < 10) hours = '0' + hours;
8+
let hodiny = datum.getHours();
9+
if (hodiny < 10) hodiny = '0' + hodiny;
1010

11-
let mins = date.getMinutes();
12-
if (mins < 10) mins = '0' + mins;
11+
let minuty = datum.getMinutes();
12+
if (minuty < 10) minuty = '0' + minuty;
1313

14-
let secs = date.getSeconds();
15-
if (secs < 10) secs = '0' + secs;
14+
let sekundy = datum.getSeconds();
15+
if (sekundy < 10) sekundy = '0' + sekundy;
1616

17-
let output = template
18-
.replace('h', hours)
19-
.replace('m', mins)
20-
.replace('s', secs);
17+
let výstup = šablona
18+
.replace('h', hodiny)
19+
.replace('m', minuty)
20+
.replace('s', sekundy);
2121

22-
console.log(output);
22+
console.log(výstup);
2323
}
2424

2525
this.stop = function() {
26-
clearInterval(timer);
26+
clearInterval(časovač);
2727
};
2828

2929
this.start = function() {
30-
render();
31-
timer = setInterval(render, 1000);
30+
vypiš();
31+
časovač = setInterval(vypiš, 1000);
3232
};
3333

3434
}
3535

36-
let clock = new Clock({template: 'h:m:s'});
37-
clock.start();
36+
let hodiny = new Hodiny({šablona: 'h:m:s'});
37+
hodiny.start();

1-js/09-classes/01-class/1-rewrite-to-class/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ importance: 5
22

33
---
44

5-
# Rewrite to class
5+
# Přepište na třídu
66

7-
The `Clock` class (see the sandbox) is written in functional style. Rewrite it in the "class" syntax.
7+
Třída `Hodiny` (viz pískoviště) je napsána funkcionálním stylem. Přepište ji do „třídní“ syntaxe.
88

9-
P.S. The clock ticks in the console, open it to see.
9+
P.S. Hodiny tikají v konzoli, otevřete si ji, abyste to viděli.

0 commit comments

Comments
 (0)