Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HospitalEmployee {
- constructor(name) {
- this._name = name;
- this._remainingVacationDays = 20;
- }
- static generatePassword(){
- return Math.floor(Math.random()*10000); //generate a number from 0 to 10,000
- }
- get name() {
- return this._name;
- }
- get remainingVacationDays() {
- return this._remainingVacationDays;
- }
- takeVacationDays(daysOff) {
- this._remainingVacationDays -= daysOff;
- }
- }
- class Nurse extends HospitalEmployee {
- constructor(name, certifications) {
- super(name);
- this._certifications = certifications;
- }
- get certifications() {
- return this._certifications;
- }
- addCertification(newCertification) { //method to add newCertification to the certifications array
- this.certifications.push(newCertification);
- }
- }
- const nurseOlynyk = new Nurse('Olynyk', ['Trauma','Pediatrics']);
- nurseOlynyk.takeVacationDays(5);
- console.log(nurseOlynyk.remainingVacationDays);
- nurseOlynyk.addCertification('Genetics');
- console.log(nurseOlynyk.certifications);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement