Skip to content

Commit 33fbcd6

Browse files
Balashov NikitaOlegLustenko
authored andcommitted
classwork-13
1 parent 5c92d00 commit 33fbcd6

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Class work 13</title>
6+
</head>
7+
<body>
8+
<script src="src/main.js"></script>
9+
</body>
10+
</html>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
function User(name) {
2+
this.name = name;
3+
4+
let cash = '111';
5+
this.getSecretCash = () => cash;
6+
this._some = () => 12;
7+
}
8+
// Статическая инкапсуляция
9+
User.static = () => 'static';
10+
11+
const test = User.static();
12+
// --- Конец ---
13+
14+
//TASK 1
15+
16+
Array.prototype.sum = function() {
17+
return this.reduce((newElem, elem) => {
18+
newElem += elem;
19+
return newElem;
20+
}, 0)
21+
}
22+
23+
const arr = [1, 2, 3];
24+
25+
console.log(arr.sum());
26+
console.log([3, 4, 5].sum());
27+
28+
// Class
29+
/*
30+
class Country{
31+
constructor({name}) {
32+
this.countryName = name;
33+
}
34+
showQwerty() {
35+
console.log('qwerty');
36+
}
37+
}
38+
39+
const ukraine = new Country({name: 'ukraine'});
40+
console.log(ukraine);
41+
ukraine.showQwerty();
42+
//-------------------
43+
class City extends Country{
44+
constructor({city}) {
45+
super();
46+
this.cityName = city;
47+
}
48+
showCity() {
49+
console.log(this.cityName);
50+
}
51+
}
52+
53+
const kharkiv = new City({city:'kharkiv'});
54+
console.log(kharkiv);
55+
kharkiv.showCity();
56+
kharkiv.showQwerty();
57+
*/
58+
//TASK 2
59+
60+
class Animal{
61+
constructor(){
62+
this.feet = 4;
63+
}
64+
65+
roar() {
66+
console.log(`Animal with ${this.feet} feet is roaring`);
67+
}
68+
}
69+
70+
const cat = new Animal();
71+
cat.roar();
72+
73+
class NeighborCat extends Animal{
74+
constructor(name){
75+
super();
76+
this.animalName = name;
77+
}
78+
79+
jump() {
80+
console.log(`
81+
_
82+
_
83+
_
84+
_
85+
`);
86+
}
87+
88+
}
89+
90+
const catMusya = new NeighborCat('Musya');
91+
console.log(catMusya)
92+
catMusya.jump();
93+
catMusya.roar();
94+
95+
//setTimeout(() => {
96+
// console.log('Nikita')
97+
//}, 1000);
98+
//
99+
//setTimeout(() => {
100+
// console.log('Nikita')
101+
//}, 3000);
102+
103+
//setTimeout(() => {
104+
// console.log('First')
105+
//}, 3000);
106+
//
107+
//setTimeout(() => {
108+
// console.log('Second')
109+
//}, 2000);
110+
//
111+
//setTimeout(() => {
112+
// console.log('Last')
113+
//}, 1000);
114+
115+
//let s = setInterval(() => {
116+
// console.log('Nikita');
117+
//}, 3000);
118+
119+
//let zero = 0;
120+
//let x = setInterval(() => {
121+
// console.log(zero += 1);
122+
//}, 1000);
123+

0 commit comments

Comments
 (0)