Created
September 18, 2018 20:15
-
-
Save mahdiyazdani/9861aaf09201e642f9ffd3df59115ff9 to your computer and use it in GitHub Desktop.
Class Methods in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Surgeon { | |
| constructor(name, department) { | |
| this._name = name; | |
| this._department = department; | |
| this._remainingVacationDays = 20; | |
| } | |
| get name() { | |
| return this._name; | |
| } | |
| get department() { | |
| return this._department; | |
| } | |
| get remainingVacationDays() { | |
| return this._remainingVacationDays; | |
| } | |
| takeVacationDays(daysOff) { | |
| return this._remainingVacationDays = this.remainingVacationDays - daysOff; | |
| } | |
| } | |
| const surgeonCurry = new Surgeon( 'Curry', 'Cardiovascular' ); | |
| const surgeonDurant = new Surgeon( 'Durant', 'Orthopedics' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment