-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccess_modifiers.ts
More file actions
94 lines (57 loc) · 2.04 KB
/
Access_modifiers.ts
File metadata and controls
94 lines (57 loc) · 2.04 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// ***************All Access-Modifiers Code Present Here*****************
// # Step : 1 Public
// class Student
// {
// public studid: number;
// studName: string;
// }
// let stud = new Student();
// stud.studid = 101;
// stud.studName = "Vishal"+ " Phone Number";
// console.log(stud.studid+ " "+stud.studName);
// ***************All Access-Modifiers Code Present Here*****************
// # Step : 1 Private
// class Student
// {
// public stud1: number;
// private studName: string;
// constructor(s1: number, name: string){
// this.stud1 = s1;
// this.studName = name;
// }
// public display()
// {
// return (`Code Access: ${this.stud1}, my name: ${this.studName}.`);
// }
// }
// let student: Student = new Student(1, "Saurabh");
// console.log(student.display());
// ***************All Access-Modifiers Code Present Here*****************
// # Step : 1 Protected
class Student
{
public studCode: number;
protected studName: string;
constructor(code: number, name: string)
{
this.studCode = code;
this.studName = name;
}
}
class Person extends Student
{
private department: string;
constructor(code: number, name: string, department: string)
{
super(code, name);
this.department = department;
}
public getElevatorPitch()
{
// If you want to Run this code then, Make a new Function With given Anytype of Name And Return some value okkk.......
// console.log(**********************Hello Access Modifiers************************);
return (`My unique code:------------------- ${this.studCode}, -------------my name: ${this.studName} -----------and I am in ${this.department} ------Branch.`);
}
}
let v1: Person = new Person(1, "v1", "CS");
console.log(v1.getElevatorPitch());