Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab with classes sample #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rpgsaga/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Phone
modelName
phoneNumber
weight
Dial()
AcceptCall()
32 changes: 32 additions & 0 deletions rpgsaga/saga/src/Phone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export class Phone {
private _modelName: string;
private _phoneNumber: string;
private _weight: number;

constructor(modelName: string, phoneNumber: string, weight: number) {
console.log('Constructor for Phone called');
this._modelName = modelName;
this._phoneNumber = phoneNumber;
this.weight = weight;
}

get weight(): number {
return this._weight;
}

set weight(weight: number) {
if (weight > 0 && weight < 2000) {
this._weight = weight;
return;
}
throw new Error('weight out of range');
}

dial(number: string) {
console.log(`Dialing ${number}`);
}

acceptCall() {
console.log(`Accepting incomming Call to ${this._phoneNumber}`);
}
}
Loading