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
14 changes: 14 additions & 0 deletions topic-3/task-1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
@param {number} minutes - Минуты
*/
function Time(hours, minutes) {

if (typeof (hours) !== "number" && typeof (minutes) !== "number" || !Number.isInteger(minutes) || !Number.isInteger(hours) || hours < 0 || minutes < 0 || hours > 24 || minutes > 60) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
думаю нужно подправить валидацию, чтобы пропускало не более 23 часов

throw new Error()
}
this.hours = hours;
this.minutes = minutes;
}

Time.prototype.isEarlier = function(time) {
return (time.minutes + time.hours * 60) > (this.hours * 60 + this.minutes);
}

Time.prototype.isLater = function (time) {
return (time.minutes + time.hours * 60) <= (this.hours * 60 + this.minutes);
}

module.exports.Time = Time;
13 changes: 13 additions & 0 deletions topic-3/task-2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
@param {Time} endTime - Время конца встречи
*/
function Meeting(meetingDate, startTime, endTime) {
if (!startTime || !endTime || startTime.hours > 19 || startTime.hours < 8 ||
startTime.minutes > 59 || startTime.minutes < 0 ||
(startTime.minutes + startTime.hours * 60) > (endTime.minutes + endTime.hours * 60) ||
endTime.hours > 19 || endTime.hours < 8 || endTime.minutes > 59 || endTime.minutes < 0) {
throw new Error();
}

this.meetingDate = meetingDate;
this.startTime = startTime;
this.endTime = endTime;
}
Meeting.prototype.isMeetingInTimeRange = function (start, end) {
return start.isEarlier(this.endTime) && end.isLater(this.startTime);
}

module.exports.Meeting = Meeting;
8 changes: 8 additions & 0 deletions topic-3/task-3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

function Vacation(vacationStartDate, vacationEndDate) {

if (!vacationStartDate || !vacationEndDate || vacationStartDate >= vacationEndDate) {
throw new Error();
}
this.vacationEndDate = vacationEndDate;
this.vacationStartDate = vacationStartDate;
}
Vacation.prototype.isDateInVacation = function(Date) {
return this.vacationStartDate <= Date && this.vacationEndDate >= Date;
}

module.exports.Vacation = Vacation;
25 changes: 23 additions & 2 deletions topic-3/task-4/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,28 @@
@param {Array<Vacation>} vacations - Массив отпусков
*/

function Organaizer(meetings = [], vacations = []) {
};
function Organaizer(meetings = [], vacations = []) {
const {Meeting} = require("../task-2");
const {Vacation} = require("../task-3");

function Organaizer(meetings = [], vacations = []) {

this.meetings = [];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
тесты не выполняются

this.vacations = [];

for( const meeting of meetings){
if(!meeting instanceof Meeting){
throw new Error()
}
this.meetings.push(meeting)
}
for( const vacation of vacations){
if(!vacation instanceof Vacation){
throw new Error()
}
this.meetings.push(vacation)
}

};

module.exports.Organaizer = Organaizer;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
тесты не выполняются, поправить

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image