From 555e08d60380db9e389a71f73b4d1e0a8167cbae Mon Sep 17 00:00:00 2001 From: alexeyvolhin <82944068+alexeyvolhin@users.noreply.github.com> Date: Sun, 3 Oct 2021 22:45:04 +0500 Subject: [PATCH 1/4] Task1 --- topic-3/task-1/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/topic-3/task-1/index.js b/topic-3/task-1/index.js index 94ab761..6a35ee6 100644 --- a/topic-3/task-1/index.js +++ b/topic-3/task-1/index.js @@ -17,6 +17,22 @@ @param {number} minutes - Минуты */ function Time(hours, minutes) { + /* проверка входных значений на адекатность */ + if (typeof(hours,minutes) !=="number" || minutes < 0 || hours < 0 || hours > 23 || minutes > 59) { + throw new Error("Time data must be number that more than 0"); + } + /* задание контекста для аргументов hours и minutes */ + this.hours = hours; + this.minutes = minutes; +} +/*Переводим в Си, делаем проверку */ +Time.prototype.isEarlier = function(Time) { + return Time.hours * 3600 + Time.minutes * 60 > this.hours * 3600 + this.minutes * 60 +} +/* аналогично предыдущему методу только later */ +Time.prototype.isLater = function(Time) { + return Time.hours * 3600 + Time.minutes * 60 < this.hours * 3600 + this.minutes * 60 + } module.exports.Time = Time; \ No newline at end of file From 0ff6c2cc2ac8648a4a5fb320ba80954421ae18ed Mon Sep 17 00:00:00 2001 From: alexeyvolhin <82944068+alexeyvolhin@users.noreply.github.com> Date: Tue, 5 Oct 2021 10:43:54 +0500 Subject: [PATCH 2/4] =?UTF-8?q?Task=202,=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA?= =?UTF-8?q?=D0=BE=20=D0=BD=D0=B5=20=D0=BF=D0=BE=D0=BD=D1=8F=D0=BB,=20?= =?UTF-8?q?=D0=B7=D0=B0=D1=87=D0=B5=D0=BC=20=D0=BD=D0=B0=D0=BC=20=D0=B3?= =?UTF-8?q?=D0=BE=D0=B4=20=D1=82=D1=83=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- topic-3/task-2/index.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/topic-3/task-2/index.js b/topic-3/task-2/index.js index 166c7d1..cb36003 100644 --- a/topic-3/task-2/index.js +++ b/topic-3/task-2/index.js @@ -7,9 +7,9 @@ Начало временного промежутка — объект класса Time Конец временного промежутка — объект класса Time Должен возвращать true, если встреча, у которой был вызван метод, - пересекает переданный временной промежутук + пересекает переданный временной промежуток 2.5. Время начала встречи должно быть больше времени конца - 2.6. Встреча может быть назначана только в промежутке между 08:00 до 19:00 + 2.6. Встреча может быть назначесна только в промежутке между 08:00 до 19:00 @constructor @this {Meeting} @param {Date} meetingDate - Дата встречи @@ -17,6 +17,26 @@ @param {Time} endTime - Время конца встречи */ function Meeting(meetingDate, startTime, endTime) { + /* минимальное значение SiStartTime не должно быть меньше (08:00) 8 * 3600 + 0 * 60 = 28800 сек + максимальное значение SiEndTime не должно быть больше (19:00) 19 * 3600 + 0 * 60 = 68400 сек */ + const SiStartTime = startTime.hours * 3600 + startTime.minutes * 60; + const SiEndTime = endTime.hours * 3600 + endTime.minutes * 60; + if (startTime > endTime || SiStartTime < 28800 || SiEndTime > 68400 ) { + throw new Error ("The meeting is only about between 8:00 and 19:00"); + } + /* задаем контекст для валидного диапазона встречи */ + this.meetingDate = meetingDate; + this.startTime = startTime; + this.endTime = endTime; +} +/* переводим в Си, сравниваем с ранее заданным диапазоном встречи */ +Meeting.prototype.isMeetingInTimeRange = function (startTime,endTime) { + const currentStartTime = this.startTime.hours * 3600 + this.startTime.minutes * 60; + const currentEndTime = this.endTime.hours * 3600 + this.endTime.minutes * 60; + const inRangeStartTime = startTime.hours * 3600 + startTime.minutes * 60; + const inRangeEndTime = endTime.hours * 3600 + endTime.minutes * 60; + + return currentEndTime > inRangeStartTime && currentStartTime < inRangeEndTime; } -module.exports.Meeting = Meeting; \ No newline at end of file +module.exports.Meeting = Meeting; From 32801b5fc82979ca1046b7f870d57e5cf6ac8f9c Mon Sep 17 00:00:00 2001 From: alexeyvolhin <82944068+alexeyvolhin@users.noreply.github.com> Date: Tue, 5 Oct 2021 13:18:24 +0500 Subject: [PATCH 3/4] task 3 --- topic-3/task-2/index.js | 2 +- topic-3/task-3/index.js | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/topic-3/task-2/index.js b/topic-3/task-2/index.js index cb36003..fb812f1 100644 --- a/topic-3/task-2/index.js +++ b/topic-3/task-2/index.js @@ -9,7 +9,7 @@ Должен возвращать true, если встреча, у которой был вызван метод, пересекает переданный временной промежуток 2.5. Время начала встречи должно быть больше времени конца - 2.6. Встреча может быть назначесна только в промежутке между 08:00 до 19:00 + 2.6. Встреча может быть назначена только в промежутке между 08:00 до 19:00 @constructor @this {Meeting} @param {Date} meetingDate - Дата встречи diff --git a/topic-3/task-3/index.js b/topic-3/task-3/index.js index b5ff228..55ee220 100644 --- a/topic-3/task-3/index.js +++ b/topic-3/task-3/index.js @@ -12,7 +12,22 @@ */ function Vacation(vacationStartDate, vacationEndDate) { - + /* проверяем данные на адекватность */ + if (vacationEndDate <= vacationStartDate || vacationStartDate === undefined || vacationEndDate === undefined) { + throw new Error ("Start date must be earlier than the end one"); + } + /*задаем контекст для валидного диапазона дат */ + this.vacationStartDate = vacationStartDate; + this.vacationEndDate = vacationEndDate; +} +/* сравниваем валидный диапазон с передаваемым в date */ +Vacation.prototype.isDateInVacation = function (date) { + if (this.vacationStartDate <= date && date <= this.vacationEndDate) { + return true; + } else { + return false; + } + /* return this.vacationStartDate <= date <= this.vacationEndDate; - не работает. Не понимаю почему. По возможности объясни, пожалуйста :)*/ + } - module.exports.Vacation = Vacation; \ No newline at end of file From c3fbd02433927bc08fc8ca216d9c56a519de2122 Mon Sep 17 00:00:00 2001 From: alexeyvolhin <82944068+alexeyvolhin@users.noreply.github.com> Date: Wed, 6 Oct 2021 22:01:36 +0500 Subject: [PATCH 4/4] Task 4 --- topic-3/task-4/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/topic-3/task-4/index.js b/topic-3/task-4/index.js index 7d670e8..ad2c343 100644 --- a/topic-3/task-4/index.js +++ b/topic-3/task-4/index.js @@ -8,7 +8,15 @@ @param {Array} vacations - Массив отпусков */ -function Organaizer(meetings = [], vacations = []) { -}; +function Organaizer(meetings = [], vacations = []) { + /* проверки агрументов */ + if (!Array.isArray(meetings) || !Array.isArray(vacations)) { + throw new Error("Arguments must be arrays"); + } + /* задание полей у класса */ + this.meetings = meetings; + this.vacations = vacations; +} + module.exports.Organaizer = Organaizer; \ No newline at end of file