From 13c2a61b78445ca2be11de0a46efebc67e92cd1a Mon Sep 17 00:00:00 2001 From: Nastya Bukina Date: Thu, 12 Jul 2018 17:29:45 +0300 Subject: [PATCH 1/2] index homework 12 --- js-core/homeworks/homework-12/index.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 js-core/homeworks/homework-12/index.html diff --git a/js-core/homeworks/homework-12/index.html b/js-core/homeworks/homework-12/index.html new file mode 100644 index 0000000..2fd82e9 --- /dev/null +++ b/js-core/homeworks/homework-12/index.html @@ -0,0 +1,12 @@ + + + + + + Homework-12 + + + + + + From d8992c52df38476a324281c47e87d434191f606e Mon Sep 17 00:00:00 2001 From: Nastya Bukina Date: Thu, 12 Jul 2018 17:30:21 +0300 Subject: [PATCH 2/2] main js homework 12 --- js-core/homeworks/homework-12/src/main.js | 62 +++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 js-core/homeworks/homework-12/src/main.js diff --git a/js-core/homeworks/homework-12/src/main.js b/js-core/homeworks/homework-12/src/main.js new file mode 100644 index 0000000..37a0ba0 --- /dev/null +++ b/js-core/homeworks/homework-12/src/main.js @@ -0,0 +1,62 @@ +// TASK 1 +// Создать класс Human, у которого будут свойства обычного человека: +// имя, возраст, пол, рост, вес. +// Используя прототипное наследование создать дочерние классы Worker +// (дописать в них поля места работы, зарплата, метод "работать") +// и Student (дописать поля места учебы, стипендией, метод "смотреть сериалы") +// +// Создать несколько экземпляров классов Worker и Student, вывести их в консоль. +// Убедиться что они имеют поля родительского класса Human + +function Human(options) { + this.name = options.name; + this.age = options.age; + this.sex = options.sex; + this.heigth = options.heigth; + this.weigth = options.weigth; +} + +function Worker(...options) { + let obj = options.reduce(elem => elem); + Human.apply(this, options); + this.company = obj.company; + this.salary = obj.salary; + this.works = () => console.log("good work!"); +} + +function Student(...options) { + let obj = options.reduce(elem => elem); + Human.apply(this, options); + this.university = options.university; + this.grants = options.grants; + this.watchSerials = () => console.log("Greate serials!"); +} + +let worker = new Worker({ + name: "nastya", + age: 24, + sex: "female", + heigth: 175, + weigth: 65, + salary: 5000, + company: "company name" +}); + +let student = new Student({ + name: "masha", + age: 20, + sex: "female", + heigth: 170, + weigth: 55, + university: "DonNTU", + grants: 500 +}); + +worker.works(); + +student.watchSerials(); + +console.log(worker); +console.log(student); + +