Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\index.js"
}
]
}
44 changes: 43 additions & 1 deletion src/task_5/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;