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
6,280 changes: 2,775 additions & 3,505 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"author": "",
"license": "ISC",
"dependencies": {
"jest": "^26.6.3"
"devDependencies": {
"jest": "^29.7.0"
}
}
43 changes: 42 additions & 1 deletion src/task_1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,47 @@
@param {number} hours - Час
@param {number} minutes - Минуты
*/
function Time(hours, minutes) { };
function Time(hours, minutes) {
try{
if(hours <= 24 && hours >= 0){
if(minutes <= 60 && minutes >= 0){
// obj = {hours, minutes};
this.hours = hours;
this.minutes = minutes;
}
else{
throw new Error('err');
}
}
else{
throw new Error('err');
}
}catch{
throw new Error('err');
}
};
Time.prototype.isEarlier = function(time){
if(this.hours < time.hours){
return true;
}
else if(this.hours === time.hours){
if(this.minutes < time.minutes){
return true;
}
}
return false;
}
Time.prototype.isLater = function(time){
if(this.hours > time.hours){
return true;
}
else if(this.hours === time.hours){
if(this.minutes >= time.minutes){
return true;
}
}
return false;

}

module.exports.Time = Time;
18 changes: 17 additions & 1 deletion src/task_2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ const { Time } = require('../task_1/index');
@param {Time} startTime - Время начала встречи
@param {Time} endTime - Время конца встречи
*/
function Meeting(meetingDate, startTime, endTime) { };
function Meeting(meetingDate, startTime, endTime) {

if (!startTime || !endTime ||
endTime.hours >= 19 || startTime.hours <= 8 ||
startTime.hours > endTime.hours) {
throw new Error('err');
}
else{
this.meetingDate = meetingDate;
this.startTime = startTime;
this.endTime = endTime;
}
};
Meeting.prototype.isMeetingInTimeRange = function(start,end){
return !(this.startTime.isLater(start) && this.startTime.isLater(end)
|| this.endTime.isEarlier(start) && this.endTime.isEarlier(end));
}

module.exports.Meeting = Meeting;
15 changes: 14 additions & 1 deletion src/task_3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
@param {Date} vacationEndDate - Время конца отпуска
*/

function Vacation(vacationStartDate, vacationEndDate) { };
function Vacation(vacationStartDate, vacationEndDate) {
if(!vacationStartDate || !vacationEndDate
|| vacationStartDate >= vacationEndDate){
throw new Error('err');
}
this.vacationStartDate = vacationStartDate;
this.vacationEndDate = vacationEndDate;
};
Vacation.prototype.isDateInVacation = function(date){
if(this.vacationStartDate <= date && this.vacationEndDate >= date){
return true;
}
return false;
}

module.exports.Vacation = Vacation;
5 changes: 4 additions & 1 deletion src/task_4/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const { Vacation } = require('../task_3/index');
@param {Array<Vacation>} vacations - Массив отпусков
*/

function Organaizer(meetings, vacations) { };
function Organaizer(meetings, vacations) {
this.meetings = meetings;
this.vacations = vacations;
};

module.exports.Organaizer = Organaizer;
31 changes: 31 additions & 0 deletions src/task_5/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,35 @@ const { Organaizer } = require('../task_4/index');
В промежуток отпуска не назначено никаких встреч
*/

Organaizer.prototype.addMeeting = function(meeting){
for (let item of this.vacations){
if (item.isDateInVacation(meeting.meetingDate)){
return false;
}
};
for (let meet of this.meetings){
if (meet.meetingDate.toString() === meeting.meetingDate.toString()
&& (meet.isMeetingInTimeRange(meeting.startTime, meeting.endTime)))
{
return false;
}
};
this.meetings.push(meeting)
return true;
}

Organaizer.prototype.addVacation = function(vacation){
for(let item of this.vacations){
if(vacation.isDateInVacation(item.vacationStartDate) || vacation.isDateInVacation(item.vacationEndDate)){
return false;
}
};
for(let meet of this.meetings){
if(vacation.isDateInVacation(meet.meetingDate))
return false;
};
this.vacations.push(vacation);
return true;
}

module.exports.Organaizer = Organaizer;