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