mk-fl8-sys 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.js +101 -0
- package/package.json +13 -0
- package/test.cjs +4 -0
- package/test.html +15 -0
package/main.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// UMD
|
|
2
|
+
(function (env, factory) {
|
|
3
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
4
|
+
module.exports = factory();
|
|
5
|
+
} else {
|
|
6
|
+
env.FlightTicket = factory();
|
|
7
|
+
}
|
|
8
|
+
})(this, function () {
|
|
9
|
+
class FlightTicket {
|
|
10
|
+
#seatNum;#flightNum;
|
|
11
|
+
#depAirport;#arrivAirport;
|
|
12
|
+
#travellingDate;
|
|
13
|
+
|
|
14
|
+
constructor(seatNum, flightNum, depAirport, arrivAirport, travellingDate=new Date()) {
|
|
15
|
+
this.seatNum = seatNum;
|
|
16
|
+
this.flightNum = flightNum;
|
|
17
|
+
this.depAirport = depAirport;
|
|
18
|
+
this.arrivAirport = arrivAirport;
|
|
19
|
+
this.travellingDate = travellingDate;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
set seatNum(value) {
|
|
23
|
+
if(!value){
|
|
24
|
+
throw new Error("SeatNum Is Required!")
|
|
25
|
+
}
|
|
26
|
+
if(typeof value !== 'string'){
|
|
27
|
+
throw new Error("Type Error!")
|
|
28
|
+
}
|
|
29
|
+
this.#seatNum = value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get seatNum() {
|
|
33
|
+
return this.#seatNum;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
set flightNum(value) {
|
|
38
|
+
if(!value){
|
|
39
|
+
throw new Error("FlightNum Is Required!")
|
|
40
|
+
}
|
|
41
|
+
if(typeof value !== 'string'){
|
|
42
|
+
throw new Error("Type Error!")
|
|
43
|
+
}
|
|
44
|
+
this.#flightNum = value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get flightNum() {
|
|
48
|
+
return this.#flightNum;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
set depAirport(value) {
|
|
53
|
+
if(!value){
|
|
54
|
+
throw new Error("depAirport Is Required!")
|
|
55
|
+
}
|
|
56
|
+
if(typeof value !== 'string'){
|
|
57
|
+
throw new Error("Type Error!")
|
|
58
|
+
}
|
|
59
|
+
this.#depAirport = value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get depAirport() {
|
|
63
|
+
return this.#depAirport;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
set arrivAirport(value) {
|
|
67
|
+
if(!value){
|
|
68
|
+
throw new Error("arrivAirport Is Required!")
|
|
69
|
+
}
|
|
70
|
+
if(typeof value !== 'string'){
|
|
71
|
+
throw new Error("Type Error!")
|
|
72
|
+
}
|
|
73
|
+
this.#arrivAirport = value;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get arrivAirport() {
|
|
77
|
+
return this.#arrivAirport;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
set travellingDate(value) {
|
|
81
|
+
if(!(value instanceof Date)){
|
|
82
|
+
throw new Error("Type Error!")
|
|
83
|
+
}
|
|
84
|
+
this.#travellingDate = value.toDateString();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get travellingDate() {
|
|
88
|
+
return this.#travellingDate;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
displayTicket() {
|
|
92
|
+
console.log('\nFlight Ticket Info:\n-------------------');
|
|
93
|
+
console.log(`Seat Number: ${this.#seatNum}`);
|
|
94
|
+
console.log(`Flight Number: ${this.#flightNum}`);
|
|
95
|
+
console.log(`Departure Airport: ${this.#depAirport}`);
|
|
96
|
+
console.log(`Arrival Airport: ${this.#arrivAirport}`);
|
|
97
|
+
console.log(`Travelling Date: ${this.#travellingDate}\n`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return FlightTicket;
|
|
101
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mk-fl8-sys",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "main.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": ["MK", "fl8", "SYSTEM"],
|
|
10
|
+
"author": "Mohamed Khaled",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"type": "commonjs"
|
|
13
|
+
}
|
package/test.cjs
ADDED
package/test.html
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Document</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<script src="main.js"></script>
|
|
10
|
+
<script>
|
|
11
|
+
const flightTicket = new FlightTicket("2MK", "12", 'CAIRO', 'ISTANBUL');
|
|
12
|
+
flightTicket.displayTicket();
|
|
13
|
+
</script>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|