From b894cfc9152ab1e096537917ae447cfdd014ef89 Mon Sep 17 00:00:00 2001 From: AlexanderKorshunov2020 Date: Wed, 31 Mar 2021 12:41:37 +0500 Subject: [PATCH 1/3] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=88=D1=83=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=20=D1=82=D0=B0=D1=81=D0=BA=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 17 +++++++++++++++++ src/task_5/index.js | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..ac44c31 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}\\index.js" + } + ] +} \ No newline at end of file diff --git a/src/task_5/index.js b/src/task_5/index.js index c49a642..3b1c2ba 100644 --- a/src/task_5/index.js +++ b/src/task_5/index.js @@ -14,5 +14,47 @@ const { Organaizer } = require('../task_4/index'); Отпуск не попадает в промежуток другого отпуска В промежуток отпуска не назначено никаких встреч */ - + Organaizer.prototype.addMeeting = function(meeting) { + for (const vacation of this.vacations) { + if (vacation.isDateInVacation(meeting.meetingDate)) { + return false; + } + } + for (const meeting_ of this.meetings) { + if (meeting_.meetingDate.toString() === meeting.meetingDate.toString()) { + const start = meeting.startTime; + const end = meeting.endTime; + if (meeting_.isMeetingInTimeRange(start, end)) { + return false; + } + } + } + this.meetings.push(meeting); + return true; + } + + Organaizer.prototype.addVacation = function(vacation) { + for (const vacation_ of this.vacations) { + if (isVacationInVacationRange(vacation_, vacation)) { + return false; + } + } + for (const meeting of this.meetings) { + if (vacation.isDateInVacation(meeting.meetingDate)) { + return false; + } + } + this.vacations.push(vacation); + return true; + } + + function isVacationInVacationRange(vacation1, vacation2) { + const start = vacation1.vacationStartDate; + const start1 = vacation2.vacationStartDate; + const end = vacation1.vacationEndDate; + const end1 = vacation2.vacationEndDate; + return !(end < start1 || end1 < start); + } + module.exports.Organaizer = Organaizer; + From c3f3ee88a6f3477e1a7ba019748f4aff669c7278 Mon Sep 17 00:00:00 2001 From: AlexanderKorshunov2020 Date: Wed, 31 Mar 2021 12:42:55 +0500 Subject: [PATCH 2/3] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=88=D1=83=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=20=D1=82=D0=B0=D1=81=D0=BA=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From ff0d239106d10c75e5eb70275724b0638e1b79f2 Mon Sep 17 00:00:00 2001 From: AlexanderKorshunov2020 Date: Wed, 31 Mar 2021 12:52:20 +0500 Subject: [PATCH 3/3] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=88=D1=83=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=20=D1=82=D0=B0=D1=81=D0=BA=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit