Skip to content

Commit 474199a

Browse files
committed
add classes intro
1 parent e9d14b7 commit 474199a

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

classes/myClass.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"use strict";
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = function (d, b) {
4+
extendStatics = Object.setPrototypeOf ||
5+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7+
return extendStatics(d, b);
8+
};
9+
return function (d, b) {
10+
if (typeof b !== "function" && b !== null)
11+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12+
extendStatics(d, b);
13+
function __() { this.constructor = d; }
14+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15+
};
16+
})();
17+
Object.defineProperty(exports, "__esModule", { value: true });
18+
console.log("hello world");
19+
var user = /** @class */ (function () {
20+
function user(email, name) {
21+
this.coursecontent = 1;
22+
this.city = "sargodha";
23+
this.email = email;
24+
this.name = name;
25+
}
26+
user.prototype.delToken = function () {
27+
console.log("Tokken deleted");
28+
};
29+
Object.defineProperty(user.prototype, "getAppleEmail", {
30+
get: function () {
31+
return "your email is ".concat(this.email);
32+
},
33+
enumerable: false,
34+
configurable: true
35+
});
36+
Object.defineProperty(user.prototype, "getCourseContent", {
37+
get: function () {
38+
return this.coursecontent;
39+
},
40+
enumerable: false,
41+
configurable: true
42+
});
43+
Object.defineProperty(user.prototype, "courseContent", {
44+
set: function (courseNum) {
45+
if (courseNum <= 1) {
46+
throw new Error("course count should be more than 1");
47+
}
48+
this.coursecontent = courseNum;
49+
},
50+
enumerable: false,
51+
configurable: true
52+
});
53+
return user;
54+
}());
55+
var subuser = /** @class */ (function (_super) {
56+
__extends(subuser, _super);
57+
function subuser() {
58+
var _this = _super !== null && _super.apply(this, arguments) || this;
59+
_this.isFamily = true;
60+
return _this;
61+
}
62+
subuser.prototype.changeCourseContent = function () {
63+
this.courseContent = 4;
64+
};
65+
return subuser;
66+
}(user));
67+
var waseem = new user("mw@gmail.com", "waseemakram");

classes/myClass.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
console.log("hello world");
2+
3+
class user {
4+
public email: string;
5+
protected coursecontent = 1;
6+
name: string;
7+
private readonly city: string = "sargodha";
8+
constructor(email: string, name: string) {
9+
this.email = email;
10+
this.name = name;
11+
}
12+
13+
private delToken() {
14+
console.log("Tokken deleted");
15+
}
16+
get getAppleEmail(): string {
17+
return `your email is ${this.email}`;
18+
}
19+
get getCourseContent(): number {
20+
return this.coursecontent;
21+
}
22+
23+
set courseContent(courseNum) {
24+
if (courseNum <= 1) {
25+
throw new Error("course count should be more than 1");
26+
}
27+
this.coursecontent = courseNum;
28+
}
29+
}
30+
31+
class subuser extends user {
32+
isFamily: boolean = true;
33+
changeCourseContent() {
34+
this.courseContent = 4;
35+
}
36+
}
37+
38+
const waseem = new user("mw@gmail.com", "waseemakram");
39+
40+
// waseem.delToken(); //Property 'delToken' is private and only accessible within class 'user'
41+
42+
// waseem.city;
43+
44+
export {};

0 commit comments

Comments
 (0)