|
@@ -0,0 +1,143 @@
|
|
|
+const studentsArr = [{
|
|
|
+ name: 'Сергей',
|
|
|
+ surname: 'Войлов',
|
|
|
+ ratingPoint: 1000,
|
|
|
+ schoolPoint: 1000,
|
|
|
+ course: 2,
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Татьяна',
|
|
|
+ surname: 'Коваленко',
|
|
|
+ ratingPoint: 880,
|
|
|
+ schoolPoint: 700,
|
|
|
+ course: 1,
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Анна',
|
|
|
+ surname: 'Кугир',
|
|
|
+ ratingPoint: 1430,
|
|
|
+ schoolPoint: 1200,
|
|
|
+ course: 3,
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Станислав',
|
|
|
+ surname: 'Щелоков',
|
|
|
+ ratingPoint: 1130,
|
|
|
+ schoolPoint: 1060,
|
|
|
+ course: 2,
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Денис',
|
|
|
+ surname: 'Хрущ',
|
|
|
+ ratingPoint: 1000,
|
|
|
+ schoolPoint: 990,
|
|
|
+ course: 4,
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Татьяна',
|
|
|
+ surname: 'Капустник',
|
|
|
+ ratingPoint: 650,
|
|
|
+ schoolPoint: 500,
|
|
|
+ course: 3,
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Максим',
|
|
|
+ surname: 'Меженский',
|
|
|
+ ratingPoint: 990,
|
|
|
+ schoolPoint: 1100,
|
|
|
+ course: 1,
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Денис',
|
|
|
+ surname: 'Марченко',
|
|
|
+ ratingPoint: 570,
|
|
|
+ schoolPoint: 1300,
|
|
|
+ course: 4,
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Антон',
|
|
|
+ surname: 'Завадский',
|
|
|
+ ratingPoint: 1090,
|
|
|
+ schoolPoint: 1010,
|
|
|
+ course: 3
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Игорь',
|
|
|
+ surname: 'Куштым',
|
|
|
+ ratingPoint: 870,
|
|
|
+ schoolPoint: 790,
|
|
|
+ course: 1,
|
|
|
+},
|
|
|
+{
|
|
|
+ name: 'Инна',
|
|
|
+ surname: 'Скакунова',
|
|
|
+ ratingPoint: 1560,
|
|
|
+ schoolPoint: 200,
|
|
|
+ course: 2,
|
|
|
+},
|
|
|
+];
|
|
|
+
|
|
|
+
|
|
|
+const budgetLimit = 5;
|
|
|
+const allowRating = 800;
|
|
|
+let id = 1;
|
|
|
+
|
|
|
+class CreateStudent {
|
|
|
+ constructor(student) {
|
|
|
+ CreateStudent.id.call(this)
|
|
|
+
|
|
|
+ this.name = student.name;
|
|
|
+ this.surname = student.surname;
|
|
|
+ this.ratingPoint = student.ratingPoint;
|
|
|
+ this.schoolPoint = student.schoolPoint;
|
|
|
+ this.isSelfPayment = (student.ratingPoint >= allowRating ) ? student.isSelfPayment = false : student.isSelfPayment = true;
|
|
|
+ this.course = student.course;
|
|
|
+ }
|
|
|
+static id = function() { return this.id = id++;};
|
|
|
+getTypeOfStudy() {if(this.isSelfPayment === false) {
|
|
|
+ return `бюджет`
|
|
|
+ }
|
|
|
+ return `контракт`
|
|
|
+ }
|
|
|
+getFullInfo() {return `Я - ${this.name} ${this.surname}, рейтинговый балл - ${this.ratingPoint}, форма обучения - ${this.getTypeOfStudy()}`};
|
|
|
+
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+let contract = [];
|
|
|
+
|
|
|
+const setAllCreatedStudentsByConstructor = arrOfStudents => {
|
|
|
+ arrOfStudents = studentsArr.map((student) => new CreateStudent(student));
|
|
|
+ arrOfStudents.sort(function(currentStudent, nextStudent) {return nextStudent.ratingPoint - currentStudent.ratingPoint || nextStudent.schoolPoint - currentStudent.schoolPoint});
|
|
|
+ arrOfStudents.map(function(student, index) {
|
|
|
+ if(index >= budgetLimit) {
|
|
|
+ student.isSelfPayment = true;
|
|
|
+ if (student.isSelfPayment === true) {
|
|
|
+ contract.push(student)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ budget = arrOfStudents.filter(student => student.isSelfPayment === false)
|
|
|
+ fullListStudents = [...budget,...contract].sort(function(currentStudent, nextStudent) {return nextStudent.ratingPoint - currentStudent.ratingPoint || nextStudent.schoolPoint - currentStudent.schoolPoint});
|
|
|
+}
|
|
|
+
|
|
|
+setAllCreatedStudentsByConstructor(studentsArr)
|
|
|
+console.log(budget)
|
|
|
+console.log(contract)
|
|
|
+console.log(fullListStudents)
|
|
|
+console.log(contract[3].getFullInfo())
|
|
|
+
|
|
|
+class Intern extends CreateStudent {
|
|
|
+
|
|
|
+ constructor(companyName) {
|
|
|
+ super(companyName);
|
|
|
+ this.companyName = companyName = 'Google';
|
|
|
+ }
|
|
|
+ getFullInternInfo() {return `Я - ${this.name} ${this.surname}, рейтинговый балл - ${this.ratingPoint}, форма обучения - ${this.getTypeOfStudy()}, интерн в компании ${this.companyName}`};
|
|
|
+}
|
|
|
+
|
|
|
+interns = fullListStudents.map((companyName) => new Intern(companyName, 'Google'))
|
|
|
+
|
|
|
+
|
|
|
+console.log(interns[3].getFullInternInfo())
|