-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.ts
40 lines (34 loc) · 773 Bytes
/
index.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
class User {
name: string;
age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
Show() {
console.log(`username: ${this.name}, age: ${this.age}`);
}
}
class Student extends User {
studentId: number;
studentGender: string;
constructor(
name: string,
age: number,
studentId: number,
studentGender: string
) {
super(name, age);
this.studentId = studentId;
this.studentGender = studentGender;
}
Show() {
console.log(
`username: ${this.name}, age: ${this.age} studentId: ${this.studentId}, studentGender: ${this.studentGender}`
);
}
}
const user = new User("John", 20);
user.Show();
const student = new Student("rahi", 19, 502386, "male");
student.Show();