Skip to content

Commit 7769844

Browse files
Balashov NikitaOlegLustenko
authored andcommitted
classwork-12
1 parent 4900cfb commit 7769844

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-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 12</title>
6+
</head>
7+
<body>
8+
<script src="src/main.js"></script>
9+
</body>
10+
</html>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
function Human(name) {
2+
this.name = name;
3+
this.isPerson = false;
4+
this.isDeveloper = false;
5+
}
6+
7+
Human.prototype.setPerson = function () {
8+
this.isPerson = true;
9+
this.drinkCoffee = function() {
10+
if(this.isPerson === true) {
11+
console.log(`Coffee`);
12+
}
13+
}}
14+
15+
Human.prototype.setDeveloper = function() {
16+
if(this.isPerson === true) {
17+
this.isDeveloper = true;
18+
}
19+
this.syaHelloWorld = function() {
20+
if(this.isDeveloper === true) {
21+
console.log(`Hello world`);
22+
}
23+
}
24+
}
25+
26+
const vasya = new Human('Vasya');
27+
28+
// TASK 2
29+
30+
function AuthorizedUser(name, password, cash) {
31+
this.name = name;
32+
const _password = password;
33+
let _userCash = cash;
34+
35+
this.showUserCash = function(predictPassword) {
36+
if(this._passwordValid(predictPassword, _password)) {
37+
console.log(_userCash);
38+
} else {
39+
console.log(`EROR 123`);
40+
}
41+
}
42+
43+
this.addCash = function(quantity, predictPassword) {
44+
if(this._passwordValid(predictPassword, _password)) {
45+
_userCash += quantity;
46+
console.log(`current cash: ${_userCash}`);
47+
} else {
48+
console.log(`EROR 123`);
49+
}
50+
}
51+
52+
}
53+
54+
AuthorizedUser._prototype.passwordValid = function(predictPassword, currentPassword) {
55+
if(predictPassword === currentPassword) {
56+
return true
57+
} else return false;
58+
}
59+
60+
61+
const user = new AuthorizedUser('user1', '12345678', 0001);

0 commit comments

Comments
 (0)