-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmployee.js
More file actions
84 lines (76 loc) · 2.74 KB
/
Employee.js
File metadata and controls
84 lines (76 loc) · 2.74 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
var User = require('./User.js')
var Cars = require('./Car.js')
var Customers = require('./Customer.js')
//client username is their email
class Employee extends User{
constructor(username, password, name, location){
super(username, password, name)
this.location = location;
}
//edits the location but only admins can use this function!!
editLocation(newLocation) {
this.location = newLocation;
return true;
}
searchCarFromLocation(carArray, location){
let carAtLocation = [];
for(let i = 0; i < carArray.length; i++){
let temp = carArray[i].GetInfo();
if(temp[1] == location){
carAtLocation.push(carArray[i])
}
}
return carAtLocation;
}
editCar(carArray, type, location, mileage, dayCost, mileCost, status, availability, editedElement, newVal) {
const info = [type, location, mileage, dayCost, mileCost, status, availability];
for (let i = 0; i < carArray.length; i++){
if(JSON.stringify(info) === JSON.stringify(carArray[i].GetInfo())){
if(editedElement == 'type'){
carArray[i].EditType(newVal);
return true;
}
else if(editedElement == 'location'){
carArray[i].EditLoc(newVal);
return true;
}
else if(editedElement == 'mileage'){
carArray[i].EditMile(newVal);
return true;
}
else if(editedElement == 'dayCost'){
carArray[i].EditDayCost(newVal);
return true;
}
else if(editedElement == 'mileCost'){
carArray[i].EditMileCost(newVal);
return true;
}
else if(editedElement == 'status'){
carArray[i].EditStatus(newVal);
return true;
}
else{
return false;
}
}
}
}
//view schedule of specific car
viewReservations(carObj) {
return carObj.GetAvail()
}
checkForClientAccount(CustomerArray, clientUsername) {
for(let i = 0; i < CustomerArray.length; i++){
if(CustomerArray[i].getUsername() == clientUsername){
return true;
}
}
return false;
}
createClientAccount(customerArray, clientName, clientUsername, password) {
//create client account if they don't have one when they first submit a reservation
customerArray.push(new Customers(clientUsername, password, clientName));
}
}
module.exports = Employee;