-
Notifications
You must be signed in to change notification settings - Fork 0
/
classes.ts
42 lines (32 loc) · 899 Bytes
/
classes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* Crie a class User com os seguintes atributos
* readonly id // Math.random().toString(36).substr(2, 9)
* private _name:string
* private _lastName:string
* set name
* set lastName
* static Title:string
* get fullName:string // concatene o Title com _name e _lastName
* logFullName():void; // loga o id e o nome do usuário
* * */
class User {
static Title: string = 'Sr(a)';
readonly id: string;
private _name: string;
private _lastName: string;
constructor() {
this.id = Math.random().toString(36).substr(2, 9);
}
set name(name: string) {
this._name = name;
}
set lastName(lastName: string) {
this._lastName = lastName;
}
get fullName(): string {
return `${User.Title} ${this._name} ${this._lastName}`;
}
logFullName(){
console.log(`Usuário ${this.id}: ${this.fullName}`);
}
}