-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeektrust.js
43 lines (35 loc) · 1.2 KB
/
geektrust.js
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
const fs = require("fs");
const addCourseOffering = require("./handlers/addCourseHandler");
const confirmAllotment = require("./handlers/allotCourseHandler");
const registerEmployee = require("./handlers/registrationHandler");
const cancelRegistration = require("./handlers/cancelationHandler");
const filename = process.argv[2];
global.db = {
courses: new Map(),
registrations: new Map(),
};
fs.readFile(filename, "utf8", (err, data) => {
/*if (err) throw err
var inputLines = data.toString().split("\n")
// Add your code here to process input commands
*/
if (err) {
throw err;
}
const inputLines = data.toString().split("\n");
// console.log(inputLines);
inputLines.forEach((line) => {
const [command, ...input] = line.split(" ");
// console.log(command, input);
if (command === "ADD-COURSE-OFFERING") {
addCourseOffering(input);
} else if (command === "ALLOT-COURSE" || command === "ALLOT") {
confirmAllotment(input);
} else if (command === "REGISTER") {
registerEmployee(input);
} else if (command === "CANCEL") {
cancelRegistration(input);
}
// console.log(global.db.courses);
});
});