Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 0 additions & 6 deletions .babelrc

This file was deleted.

104 changes: 104 additions & 0 deletions Admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
//just making this as a template change anything you want

//trying to import cars and employees class, not working
import Employee from './Employee'
import Car from './Car'
import Customer from './Customer'
import User from './User'

// var Employee = require('./Employee')
// var Car = require('./Car')
// var Customer = require('./Customer')
// var User = require('./User')

class Admin extends Employee{
constructor(username, password, name, location) {
//constructor
super(username, password, name, location);
}
addEmployee;
deleteEmployee;
editEmployeeLocation;
getAdminUsername;
addAdmin;
deleteAdmin;
editAdminUsername;
editAdminLocation;
editAdminsPassword;
}

Admin.prototype.addEmployee = function(employeeArray, username, password, location) {
employeeArray.push(Employee(username, password, location));
return employeeArray; //may not need
}

Admin.prototype.deleteEmployee = function(employeeArray, username) {
for(let i = 0; i < employeeArray.length; i++){
if(username.equals(employeeArray[i].getEmployeeUsername)){
delete employeeArray[i];
}
}
return employeeArray; //may not need
}

Admin.prototype.editEmployeeLocation = function(employeeArray, username, location) {
for(let i = 0; i < employeeArray.length; i++){
if(username.equals(employeeArray[i].getEmployeeUsername)){
employeeArray[i].editEmployeeLocation(location);
break;
}
}
return employeeArray; //may not need
}

Admin.prototype.getAdminUsername = function() {
return this.username
}

Admin.prototype.addAdmin = function(adminArray, username, password, location) {
adminArray.push(Admin(username, password, location));
return adminArray; //may not need
}

Admin.prototype.deleteAdmin = function(adminArray, username) {
for(let i = 0; i < adminArray.length; i++){
if(username.equals(adminArray[i].getAdminUsername)){
delete adminArray[i];
}
}
return adminArray; //may not need
}

Admin.prototype.editAdminUsername = function(adminArray, oldUsername, newUsername) {
for(let i = 0; i < adminArray.length; i++){
if(oldUsername.equals(adminArray[i].getAdminUsername)){
adminArray[i].username = newUsername;
break;
}
}
return employeeArray; //may not need
}

Admin.prototype.editAdminPassword = function(adminArray, username, password) {
for(let i = 0; i < adminArray.length; i++){
if(username.equals(adminArray[i].getAdminUsername)){
adminArray[i].password = password;
break;
}
}
return employeeArray; //may not need
}

Admin.prototype.editAdminLocation = function(username, location) {
for(let i = 0; i < adminArray.length; i++){
if(username.equals(adminArray[i].getAdminUsername)){
adminArray[i].location = location;
break;
}
}
return employeeArray; //may not need
}



module.export = Admin;
173 changes: 0 additions & 173 deletions Admins.js

This file was deleted.

108 changes: 108 additions & 0 deletions Car.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
class Car {
constructor(type, location, mileage, dayCost, mileCost, status, availability) {
//constructor
this.typeC = type;
this.locationC = location;
this.mileageC = mileage;
this.dayCostC = dayCost;
this.mileCostC = mileCost;
this.statusC = status;
this.availabilityC = new Map(availability);
}
GetInfo;
EditType;
EditLoc;
EditMile;
EditDayCost;
EditMileCost;
EditStatus;
EditAvail;
CheckAvail;
AddReserve;
GetAvail;
}

Car.prototype.GetInfo = function() {
return [this.typeC, this.locationC, this.mileageC, this.dayCostC, this.mileCostC, this.statusC, this.availabilityC]
}

Car.prototype.EditType = function(type) {
this.typeC = type;
}

Car.prototype.EditLoc = function(location) {
this.locationC = location;
}

Car.prototype.EditMile = function(miles) {
this.mileageC = miles;
}

Car.prototype.EditDayCost = function(dayCost) {
this.dayCostCC = dayCost;
}

Car.prototype.EditMileCost = function(mileCost) {
this.mileCostC = mileCost;
}

Car.prototype.EditStatus = function(status) {
this.statusC = status;
}

Car.prototype.EditAvail = function(availability) {
this.availabilityC = availability;
}

//check the availability of this car
Car.prototype.CheckAvail = function(startDate, endDate, startTime, endTime) {
startDate = new Date(startDate);
endDate = new Date(endDate);


}

//add a reservation for this car
//ensure the startTime and endTime are in military time
Car.prototype.AddReserve = function(startDate, endDate, startTime, endTime) {
startDate = new Date(startDate);
endDate = new Date(endDate);

//cannot use normal == for date objects
if(startDate.toString() == endDate.toString()){
let existingPeriods = availabilityC.get(startDate) || [];
existingPeriods.push([startTime, endTime]);
existingPeriods.sort();
availabilityC.set(startDate, existingPeriods);
}
else{
//reserving the startDate, endDate, and the in between days
let existingPeriods = availabilityC.get(startDate) || [];
existingPeriods.push([startTime, '23:59']);
existingPeriods.sort();
availabilityC.set(startDate, existingPeriods);

existingPeriods = availabilityC.get(endDate) || [];
existingPeriods.push(['00:00', endTime]);
existingPeriods.sort();
availabilityC.set(endDate, existingPeriods);

//make temp 1 day ahead of startDate
let temp = new Date(startDate)
temp.setDate(startDate.getDate() + 1)

console.log("temp: " + temp)

for(let i = temp; i < endDate; i.setDate(i.getDate() + 1)){
existingPeriods = availabilityC.get(i) || [];
existingPeriods.push(['00:00', '23:59']);
availabilityC.set(new Date(i), existingPeriods)
}
}
}

Car.prototype.GetAvail = function() {
return this.availabilityC;
}

module.export = Car;
Loading