-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75c060a
commit b57735a
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export class Phone { | ||
private aYear: number; | ||
phoneNumber: string; | ||
|
||
static phoneCount = 0; | ||
|
||
constructor(number: string, year: number, public name?: string) { | ||
Phone.phoneCount += 1; | ||
this.phoneNumber = number; | ||
this.year = year; | ||
this.name = name; | ||
} | ||
|
||
call(number: string) { | ||
console.log(`Making a call from ${this.phoneNumber} to ${number}`); | ||
} | ||
endCall() { | ||
console.log('Ending call'); | ||
} | ||
|
||
set year(year: number) { | ||
this.aYear = year >= 1900 && year < 2023 ? year : this.aYear ?? 1900; | ||
} | ||
|
||
get year(): number { | ||
return this.aYear; | ||
} | ||
} | ||
|