Skip to content

Melanin Nikita #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
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
8 changes: 0 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion topic-3/task-1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
@param {number} minutes - Минуты
*/
function Time(hours, minutes) {
}
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;
};
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;
13 changes: 12 additions & 1 deletion topic-3/task-2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@
@param {Time} startTime - Время начала встречи
@param {Time} endTime - Время конца встречи
*/
const {Time} = require("../task-1");
function Meeting(meetingDate, startTime, endTime) {
}
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;
this.endTime = endTime;
};
Meeting.prototype.isMeetingInTimeRange = function(start, end) {
return start.isEarlier(this.endTime) && end.isLater(this.startTime);
Copy link

Choose a reason for hiding this comment

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

Не все возможные случаи

};

module.exports.Meeting = Meeting;
10 changes: 9 additions & 1 deletion topic-3/task-3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
};
Copy link

Choose a reason for hiding this comment

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

2 балла


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

function Organaizer(meetings = [], 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;
Copy link

Choose a reason for hiding this comment

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

Проверка на входные данные?

Copy link
Author

Choose a reason for hiding this comment

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

У нас же указано, что поступает: "массив данных", зачем делать проверку?

Copy link

Choose a reason for hiding this comment

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

Затем, что мне ничего не запрещает прокинуть туда что-то иное.

this.vacations = vacations;
};

module.exports.Organaizer = Organaizer;