From b57735a4b6709d271b6f7a50a53b9eceae710c3a Mon Sep 17 00:00:00 2001 From: RedMarshal Date: Thu, 9 Nov 2023 17:14:21 +0300 Subject: [PATCH] return phone class --- rpgsaga/saga/src/phone.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 rpgsaga/saga/src/phone.ts diff --git a/rpgsaga/saga/src/phone.ts b/rpgsaga/saga/src/phone.ts new file mode 100644 index 0000000..6e9e03c --- /dev/null +++ b/rpgsaga/saga/src/phone.ts @@ -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; + } + } + \ No newline at end of file