-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
80 lines (64 loc) · 1.59 KB
/
app.ts
File metadata and controls
80 lines (64 loc) · 1.59 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
interface Student {
firstName: string;
lastName: string;
study(hours: number | string): void
}
class Person implements Student {
public firstName: string;
public lastName: string;
age: number;
readonly code: number | string;
static id: number = 0;
constructor(firstName, lastName, Age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = Age;
}
study(hours: number): void {
alert('I\'ve studied' + hours + ' hours.');
}
static sleep() {
return 'Im sleeping';
}
public Firstname() {
return this.firstName;
}
get Age() {
return this.age;
}
set Age(age: number) {
this.age = age;
}
}
class Mostafa extends Person {
setNewName(name: string): void {
this.firstName = super.Firstname + name;
}
wakeup = (hours: number): string => {
return 'Im sleeping' + hours + 'hours';
}
}
enum Role { ADMIN, Author}
const mostafa = new Mostafa('mostafa', 'jamali', 24);
Mostafa.id++;
Mostafa.sleep();
mostafa.age = 24.5;
alert(mostafa.setNewName("MohammadAmin"));
const myobject: {
fname: string;
lname: string;
hobbies: string[];
role: [number, string];//first element should be number then the second should be string
role2: [number, any];
role3: Role;
} = {
fname: 'Mostafa',
lname: 'Jamali',
hobbies: ['reading', 'sleeping'],
role3: Role.Author;
};
myobject.role = [1, 'st'];
myobject.role = [3.5, 'two'];
console.log(myobject.role3);
console.log(myobject.fname);
console.log(myobject.hobbies);