final
This commit is contained in:
		
							
								
								
									
										1
									
								
								task2/1/app.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								task2/1/app.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| const greeting = require('./greeting'); | ||||
							
								
								
									
										1
									
								
								task2/1/greeting.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								task2/1/greeting.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| console.log('greeting module'); | ||||
							
								
								
									
										8
									
								
								task2/2/app.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								task2/2/app.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| const os = require('os'); | ||||
| const greeting = require('./greeting'); | ||||
|  | ||||
| // получим имя текущего пользователя | ||||
| let userName = os.userInfo().username; | ||||
|  | ||||
| console.log(`Дата запроса: ${greeting.date}`); | ||||
| console.log(greeting.getMessage(userName)); | ||||
							
								
								
									
										9
									
								
								task2/2/greeting.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								task2/2/greeting.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| let currentDate = new Date(); | ||||
| module.exports.date = currentDate; | ||||
|  | ||||
| module.exports.getMessage = function (name) { | ||||
|     let hour = currentDate.getHours(); | ||||
|     if (hour > 16) return 'Добрый вечер, ' + name; | ||||
|     else if (hour > 10) return 'Добрый день, ' + name; | ||||
|     else return 'Доброе утро, ' + name; | ||||
| }; | ||||
							
								
								
									
										5
									
								
								task2/3/app.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								task2/3/app.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
|  | ||||
| const User = require('./user.js'); | ||||
|  | ||||
| let eugene = new User('Eugene', 32); | ||||
| eugene.sayHi(); | ||||
							
								
								
									
										9
									
								
								task2/3/greeting.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								task2/3/greeting.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| let currentDate = new Date(); | ||||
| module.exports.date = currentDate; | ||||
|  | ||||
| module.exports.getMessage = function (name) { | ||||
|     let hour = currentDate.getHours(); | ||||
|     if (hour > 16) return 'Добрый вечер, ' + name; | ||||
|     else if (hour > 10) return 'Добрый день, ' + name; | ||||
|     else return 'Доброе утро, ' + name; | ||||
| }; | ||||
							
								
								
									
										14
									
								
								task2/3/user.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								task2/3/user.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| function User(name, age) { | ||||
|     this.name = name; | ||||
|     this.age = age; | ||||
|     this.displayInfo = function () { | ||||
|         console.log( | ||||
|             `Имя: ${this.name}  Возраст: ${this.age}` | ||||
|         ); | ||||
|     }; | ||||
| } | ||||
| User.prototype.sayHi = function () { | ||||
|     console.log(`Привет, меня зовут ${this.name}`); | ||||
| }; | ||||
|  | ||||
| module.exports = User; | ||||
		Reference in New Issue
	
	Block a user
	 kogleee
					kogleee