Добрый день) Мне нужно выполнить эти задания что бы пройти собеседование в одной компаний, на первую работу) Вот задания:
Используйте класс Person и расширьте его для классов Employee и Customer;
Объект Person имеет приватное свойство "name" и getter метод для "name".
Класс Employee имеет две приватные свойства: "hire date"(дата принятия на работу) и "salary"(зарплата). Они также имеют методы getter для этих своиств.
Класс Customer имеет приватное свойство "contract number" (номер договора) и getter для номера договора.
//4)Create a Person class
class Person{
constructor(firstName, lastName) {
this.firstname = firstName;
this.lastname = lastName;
this._name = name; // create a private name property for the Person class
// create a getter method for the name for the Person class
this.getName = function () {
return this._name;
};
this.getFullName = function() {
return this.firstname+ " " + this.lastname;
};
}
}
// extend Person class for the Employee and Customer classes.
class Employee extends Person {
constructor(_hireDate, _salary){
this._hiredate = hireDate; // create a private property hire date for Employee class
this._salary = salary; // create a private property salary for Employee class
// create a getter method for the hire date
this.getHireDate = function(){
return this._hiredate;
};
// create a getter method for the salary
this.getSalary = function(){
return this._salary;
};
}
}
class Customer extends Person {
constructor(){
this._contractNumber = contractNumber; // create a private contract number for Customer class
//create a getter for the contract number.
this.getcontractNumber = function(){
return this._contractNumber;
};
};
}
Вроде сделал как знаю на данный момент, но выдаёт ошибки. Я закрепил фото. И может у кого-то есть советы, и скажет как сделать правильно. Буду очень благодарен всем!!!
Bроде сейчас попробовал добавил "super()", и уже не выдаёт ошибку, и можно создавать новый объекты с классом Customer и Employee ) вроде работает, надеюсь правильно сделал.
class Person{
constructor(firstName, lastName) {
this.firstname = firstName;
this.lastname = lastName;
this._name = name; // create a private name property for the Person class
// create a getter method for the name for the Person class
this.getName = function () {
return this._name;
};
this.getFullName = function() {
return this.firstname+ " " + this.lastname;
};
}
}
// extend Person class for the Employee and Customer classes.
class Employee extends Person {
constructor(hireDate, salary){
super(hireDate, salary);
this._hiredate = hireDate; // create a private property hire date for Employee class
this._salary = salary; // create a private property salary for Employee class
// create a getter method for the hire date s
this.getHireDate = function(){
return this._hiredate;
};
// create a getter method for the salary
this.getSalary = function(){ //varianta alternativa: Employee.prototype.getSalary = function(){
return this._salary;
};
}
}
class Customer extends Person {
constructor(contractNumber){
super(contractNumber);
this._contractNumber = contractNumber; // create a private contract number for Customer class
//create a getter for the contract number.
this.getcontractNumber = function(){
return this._contractNumber;
};
};
}
Оборудование для ресторана: новинки профессиональной кухонной техники
Частный дом престарелых в Киеве: комфорт, забота и профессиональный уход
Люди добрые, хочу просто получить удаленно файл по маске с сервера и сохранить к себе в папкуВсе, что перед
Как скрыть кнопку от всех, кроме пользователя, который находится в таблице users и имеет e-mail: igor@gmailcom Возможно такое реализовать? К примеру, такая...
На данный вопрос уже ответили:
Почему получается 1491625 ? Не могу понять смысл цикла, идет 1, потом 1++ = 2, далее 2 * 2 = 4, 4++ = 5, 5 * 5 = 25