From fc5d0b0802ec53e11c9f83fc1ea1acc51388f1bb Mon Sep 17 00:00:00 2001 From: URFUTEAM Date: Mon, 4 Oct 2021 20:33:20 +0500 Subject: [PATCH 1/5] done: all tasks --- package-lock.json | 8 -------- topic-3/task-1/index.js | 15 +++++++++++++-- topic-3/task-2/index.js | 11 ++++++++++- topic-3/task-3/index.js | 10 +++++++++- topic-3/task-4/index.js | 2 ++ 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index e20190a..aea54a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "js-task-3", "version": "1.0.0", "license": "ISC", "devDependencies": { @@ -10715,13 +10714,6 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", diff --git a/topic-3/task-1/index.js b/topic-3/task-1/index.js index 94ab761..4c8f786 100644 --- a/topic-3/task-1/index.js +++ b/topic-3/task-1/index.js @@ -16,7 +16,18 @@ @param {number} hours - Час @param {number} minutes - Минуты */ -function Time(hours, minutes) { -} +function Time(hours, minutes){ + if (hours < 0 || hours > 24 || minutes < 0 || minutes > 60) { + throw new UserException("Invalid time") + }; + this.hours = hours; + this.minutes = minutes; +}; +Time.prototype.isEarlier = function(time){ + return time.hours * 60 + time.minutes > this.hours * 60 + this.minutes; +}; +Time.prototype.isLater = function(time){ + return !this.isEarlier(time); +}; module.exports.Time = Time; \ No newline at end of file diff --git a/topic-3/task-2/index.js b/topic-3/task-2/index.js index 166c7d1..421edd5 100644 --- a/topic-3/task-2/index.js +++ b/topic-3/task-2/index.js @@ -17,6 +17,15 @@ @param {Time} endTime - Время конца встречи */ function Meeting(meetingDate, startTime, endTime) { -} + if (startTime.hours < 8 || endTime.hours > 19 || startTime > endTime){ + throw new UserException ("Invalid time"); + }; + 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; \ No newline at end of file diff --git a/topic-3/task-3/index.js b/topic-3/task-3/index.js index b5ff228..d944d72 100644 --- a/topic-3/task-3/index.js +++ b/topic-3/task-3/index.js @@ -12,7 +12,15 @@ */ function Vacation(vacationStartDate, vacationEndDate) { + if (!(vacationEndDate instanceof Date && vacationStartDate instanceof Date) || (vacationStartDate >= vacationEndDate)){ + throw new UserException ("Invalid date vacation"); + }; + this.vacationStartDate = vacationStartDate; + this.vacationEndDate = vacationEndDate; +}; +Vacation.prototype.isDateInVacation = function(date){ + return date >= this.vacationStartDate && date <= this.vacationEndDate; -} +}; module.exports.Vacation = Vacation; \ No newline at end of file diff --git a/topic-3/task-4/index.js b/topic-3/task-4/index.js index 7d670e8..35c2236 100644 --- a/topic-3/task-4/index.js +++ b/topic-3/task-4/index.js @@ -9,6 +9,8 @@ */ function Organaizer(meetings = [], vacations = []) { + this.meetings = meetings; + this.vacations = vacations; }; module.exports.Organaizer = Organaizer; \ No newline at end of file From 7efcba58ab8ed9b7209e947ec892b6470c8033d0 Mon Sep 17 00:00:00 2001 From: URFUTEAM Date: Mon, 4 Oct 2021 20:37:52 +0500 Subject: [PATCH 2/5] d --- topic-3/task-1/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/topic-3/task-1/index.js b/topic-3/task-1/index.js index 4c8f786..f4743b1 100644 --- a/topic-3/task-1/index.js +++ b/topic-3/task-1/index.js @@ -23,9 +23,11 @@ function Time(hours, minutes){ this.hours = hours; this.minutes = minutes; }; + Time.prototype.isEarlier = function(time){ return time.hours * 60 + time.minutes > this.hours * 60 + this.minutes; }; + Time.prototype.isLater = function(time){ return !this.isEarlier(time); }; From 2a6273489d90ec9bc9bc1b9eb3efe93061e0b330 Mon Sep 17 00:00:00 2001 From: URFUTEAM Date: Mon, 4 Oct 2021 20:42:12 +0500 Subject: [PATCH 3/5] c --- topic-3/task-1/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/topic-3/task-1/index.js b/topic-3/task-1/index.js index f4743b1..1fa9178 100644 --- a/topic-3/task-1/index.js +++ b/topic-3/task-1/index.js @@ -16,18 +16,16 @@ @param {number} hours - Час @param {number} minutes - Минуты */ -function Time(hours, minutes){ +function Time(hours, minutes) { if (hours < 0 || hours > 24 || minutes < 0 || minutes > 60) { throw new UserException("Invalid time") }; this.hours = hours; - this.minutes = minutes; + this.minutes = minutes }; - Time.prototype.isEarlier = function(time){ return time.hours * 60 + time.minutes > this.hours * 60 + this.minutes; }; - Time.prototype.isLater = function(time){ return !this.isEarlier(time); }; From b3dd8f556eddd4f5113083717eb085eb32decd48 Mon Sep 17 00:00:00 2001 From: URFUTEAM Date: Sat, 9 Oct 2021 11:28:58 +0500 Subject: [PATCH 4/5] fix: 1,2,4 tasks --- topic-3/task-1/index.js | 7 ++++--- topic-3/task-2/index.js | 6 ++++-- topic-3/task-4/index.js | 3 +++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/topic-3/task-1/index.js b/topic-3/task-1/index.js index 1fa9178..fff6b80 100644 --- a/topic-3/task-1/index.js +++ b/topic-3/task-1/index.js @@ -17,11 +17,12 @@ @param {number} minutes - Минуты */ function Time(hours, minutes) { - if (hours < 0 || hours > 24 || minutes < 0 || minutes > 60) { - throw new UserException("Invalid time") + if (hours < 0 || hours > 24 || minutes < 0 || minutes > 60 + || !Number.isInteger(hours) || !Number.isInteger(minutes)){ + throw new UserException('Invalid time'); }; this.hours = hours; - this.minutes = minutes + this.minutes = minutes; }; Time.prototype.isEarlier = function(time){ return time.hours * 60 + time.minutes > this.hours * 60 + this.minutes; diff --git a/topic-3/task-2/index.js b/topic-3/task-2/index.js index 421edd5..9fe64d1 100644 --- a/topic-3/task-2/index.js +++ b/topic-3/task-2/index.js @@ -17,8 +17,10 @@ @param {Time} endTime - Время конца встречи */ function Meeting(meetingDate, startTime, endTime) { - if (startTime.hours < 8 || endTime.hours > 19 || startTime > endTime){ - throw new UserException ("Invalid time"); + const {Time} = require("../task-1"); + if (startTime.hours < 8 || endTime.hours > 19 || startTime > endTime + || !(meetingDate instanceof Date) || !(startTime instanceof Time) || !(endTime instanceof Time)){ + throw new UserException('Invalid time'); }; this.meetingDate = meetingDate; this.startTime = startTime; diff --git a/topic-3/task-4/index.js b/topic-3/task-4/index.js index 35c2236..a008799 100644 --- a/topic-3/task-4/index.js +++ b/topic-3/task-4/index.js @@ -9,6 +9,9 @@ */ function Organaizer(meetings = [], vacations = []) { + if(!Array.isArray(meetings) && !Array.isArray(vacations)) { + throw new UserException("Invalid Array"); + }; this.meetings = meetings; this.vacations = vacations; }; From 9331c6ec61b2aec9b906017961636665b02195af Mon Sep 17 00:00:00 2001 From: URFUTEAM Date: Sun, 10 Oct 2021 23:09:44 +0500 Subject: [PATCH 5/5] fix: some er --- topic-3/task-2/index.js | 2 +- topic-3/task-4/index.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/topic-3/task-2/index.js b/topic-3/task-2/index.js index 9fe64d1..179f894 100644 --- a/topic-3/task-2/index.js +++ b/topic-3/task-2/index.js @@ -16,8 +16,8 @@ @param {Time} startTime - Время начала встречи @param {Time} endTime - Время конца встречи */ +const {Time} = require("../task-1"); function Meeting(meetingDate, startTime, endTime) { - const {Time} = require("../task-1"); if (startTime.hours < 8 || endTime.hours > 19 || startTime > endTime || !(meetingDate instanceof Date) || !(startTime instanceof Time) || !(endTime instanceof Time)){ throw new UserException('Invalid time'); diff --git a/topic-3/task-4/index.js b/topic-3/task-4/index.js index a008799..15f07ea 100644 --- a/topic-3/task-4/index.js +++ b/topic-3/task-4/index.js @@ -8,8 +8,12 @@ @param {Array} vacations - Массив отпусков */ -function Organaizer(meetings = [], vacations = []) { - if(!Array.isArray(meetings) && !Array.isArray(vacations)) { +const { Meeting } = require("../task-2"); +const { Vacation } = require("../task-3"); + +function Organaizer(meetings = [], vacations = []){ + if(!Array.isArray(meetings) || !Array.isArray(vacations) + ||meetings.some(x => !(x instanceof Meeting)) || meetings.some(x => !(x instanceof Vacation))){ throw new UserException("Invalid Array"); }; this.meetings = meetings;